【问题标题】:How fix this : error: no member named 'setBackgroundColor' in 'QTableWidgetItem'?如何解决这个问题:错误:'QTableWidgetItem'中没有名为'setBackgroundColor'的成员?
【发布时间】:2022-01-19 22:40:18
【问题描述】:
ui -> tablica -> item(i, j) -> text().toInt(&f1);
               if(f1)
               {
                   ui -> tablica -> item(i, j) -> setBackgroundColor(Qt::white);
               }

setBackgroundColor 方法出错。

【问题讨论】:

  • setBackgroundColor 似乎已从 Qt6 中删除,因为 QTableWidgetItem 的过时成员不再列在 documentation 中。

标签: c++ qt


【解决方案1】:

使用:void QTableWidgetItem::setBackground(const QBrush &brush)

在这里查看原因:

https://doc.qt.io/qt-5/qtablewidgetitem-obsolete.html#setBackgroundColor

void QTableWidgetItem::setBackgroundColor(const QColor &color) 此功能已过时。提供它是为了保持旧的源代码正常工作。我们强烈建议不要在新代码中使用它。 此功能已弃用。请改用 setBackground()。 另请参见 backgroundColor()。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 1970-01-01
    • 1970-01-01
    • 2017-06-11
    • 1970-01-01
    相关资源
    最近更新 更多