Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果一个单元格有一些数据,使用
tableWidget->item(8,0)->setBackgroundColor(Qt::red);
更改背景颜色将起作用,但如果单元格为空白,它将失败。
您不能设置单元格的背景颜色,除非它包含 a QTableWidgetItem(因为背景颜色是项目的属性)。
QTableWidgetItem
所以你需要先QTableWidget用空项目填充你的。在您的示例中,在尝试设置背景颜色之前创建项目。
QTableWidget
tableWidget->setItem(8, 0, new QTableWidgetItem); tableWidget->item(8, 0)->setBackground(Qt::red);
另请注意,您应该使用setBackground而不是,setBackgroundColor因为后者已被弃用。
setBackground
setBackgroundColor
I am having a problem displaying data from my DB in a list view. the below is the code from for my display method.
Display
public ArrayList<Object> display(String r
2 prolog - 如何在 Prolog 中设置 arg 的值?
1 haskell - 在 Haskell 中替换字符串
1 c++ - C++ 链接器错误未定义对 Linux 上的类定义及其成员函数的引用
1 java - Java 2D 游戏开发:多键输入
0 vb.net - 定位动态创建的按钮
3 google-apps-script - Google 电子表格 - 如何修改已分配脚本的图像?
2 c# - 格式化动态下拉列表文本(金钱)
2 r - R-在两个数据框中查找匹配列以进行 t 检验统计(R 初学者)
2 mysql - MYSQL 秒列时间
Reference php × 1429865 c/c++ × 756500 nginx × 49975 mongodb × 159057 mybatis × 3233 anaconda × 13410 pycharm × 14671 python × 1902243 vscode × 56040 docker × 110988 github × 49000 flask × 49129 ffmpeg × 24037 jmeter × 16910 matplotlib × 63493 bootstrap × 54641