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.
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.