About ReDraw button on QWidget
-
I have a problem as:
@
int nViTri = (10 - sDapAnNhanDc.length()) / 2;
for(int i = 0; i < _arrKyTuDapAn->count(); i++)
{
CongCuGiaoDien::log(this, "hienThiDapAn >>> nVitri hien thi: " + QString::number(nViTri).toAscii());
QPushButton *_btnTemp = new QPushButton(ui->_widKetQua);
_btnTemp->setGeometry(nViTri * 35, 15, 35, 35);
_btnTemp->setEnabled(true);
_btnTemp->setStyleSheet(".QPushButton{border-image: none; background-color: rgba(255, 255, 255, 0);}");
_arrViTriCacDapAn->append(_btnTemp);
}
@
when i want to update the nViTri with new formula, my buttons on widget NO Redraw although i had use Update() or etc....
how to solve it!
Thanks for all support! -
So... how many items are in _arrkYTuDapAn? Is that in the order of magnitude of 10, 100, 10000?
Note that changing visible properties of items on the screen will only result in a a repaint event being queued in the eventqueue. You need to give the eventqueue time to actually do the repaints too, at some point. That will happen after your loop is done. If that is too late for you, you should considder either breaking up your loop in multiple runs over parts of the array, or perhaps call QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers) once every few iterations. -
How did you tried to update your buttons?