PDA

View Full Version : Why cellWidgets in a QTableWidget can not scroll when it's in a QGraphicsScene?



Mavis
19th July 2010, 07:06
I need some animation with QTableWidget, so using QGraphicsScene and QGraphicsView.
When I scroll the table's scrollbar, the cellWidgets can not scroll or update at all but the QTableWidgetItem can!

Please see the attachment for my screenshot: The first picture Screenshot.png is not correctly scroll.
The second picture Screenshot-1.png is correctly scroll. This table shown correct when there's no view/scene.

Below is my code:


#include <QtGui>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsScene scene;
scene.setSceneRect(0, 0, 400, 200);

QTableWidget *table = new QTableWidget;
table->setColumnCount(2);
table->setRowCount(10);

for (int i=0; i<10; i++) {
QString str;
str.setNum(i);
table->setItem(i, 0, new QTableWidgetItem(str));
table->setCellWidget(i, 1, new QPushButton(str));
}

scene.addWidget(table);

QGraphicsView *view = new QGraphicsView(&scene);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
view->show();

return app.exec();
}

Is it a bug of QT4.6?
Can anyone tell me the reason? Thanks.

Mavis
19th July 2010, 07:17
Version: qt4.6, pyqt4.7

nemmartins
27th June 2011, 18:59
Hi there... did you found a solution for that problem,, I'm having the same issue here....

Thanks