0
用下面的代碼,我們用來設置行的背景色在QTableView中盤旋在它時:在Qt5的QTableView中繪製行背景是不可能的了?
void StableTable::mouseMoveEvent (QMouseEvent * event) {
int row = rowAt (event->y());
if(row == -1) return;
if (row == mHoveredRow) return;
QBrush background(palette().midlight());
QColor backColor = background.color();
background.setColor(backColor);
for (int col = 0; col < model()->columnCount(); col++) {
QModelIndex inn = model()->index(row, col);
model()->setData(inn, background, Qt::BackgroundRole);
if(mHoveredRow != -1) {
QModelIndex prevInn = model()->index(mHoveredRow, col);
model()->setData(prevInn, palette().base(), Qt::BackgroundRole);
}
}
mHoveredRow = row;
}
它好工作與Qt4.8.x但現在隨着Qt5.4無背景色IST設置了。有沒有人有線索,如果這裏發生了什麼變化?