Help me ,about the QGraphicsView ,it flicker always in my aplication
-
here is my code:
@
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
resize(1000,500);
//body
QGraphicsView *pBody = new QGraphicsView(this);QGraphicsScene *pSBody = new QGraphicsScene(); pSBody->setSceneRect(0,0,800,400); pBody->setScene(pSBody); pBody->setGeometry(QRect(100,50,800,400)); pBody->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); pBody->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //无边框设置 pBody->setFrameShape(QFrame::NoFrame); //设置背景透明 pBody->setBackgroundRole(QPalette::Background); pBody->setPalette(QPalette(QColor(255,0,0,0))); pBody->setStyleSheet(QString("QGraphicsView{background-color:#66cc33;}")); QGraphicsProxyWidget *pDivProxy = new QGraphicsProxyWidget(); pDivProxy->setParent(this); QGraphicsView *pDiv = new QGraphicsView(); QGraphicsScene *pSDiv = new QGraphicsScene(); pSDiv->setSceneRect(0,0,600,200); pDiv->setScene(pSDiv); pDiv->resize(600,200); pDiv->setGeometry(QRect(100,100,600,200)); pDiv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); pDiv->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); pDiv->setStyleSheet(QString("QGraphicsView{background-color:#22ccFF;}")); pDivProxy->setGeometry(QRect(100,100,600,200)); pDivProxy->setPos(100.0,100.0); pDivProxy->setWidget(pDiv); pSBody->addItem(pDivProxy); QGraphicsProxyWidget *pNumProxy = new QGraphicsProxyWidget(); QGraphicsProxyWidget *pPowProxy = new QGraphicsProxyWidget(); QGraphicsProxyWidget *pSumProxy = new QGraphicsProxyWidget(); QLineEdit *pNum = new QLineEdit(); QLineEdit *pPow = new QLineEdit(); QLineEdit *pSum = new QLineEdit(); pNumProxy->setWidget(pNum); pPowProxy->setWidget(pPow); pSumProxy->setWidget(pSum); pNumProxy->setGeometry(QRect(20,20,100,30)); pPowProxy->setGeometry(QRect(20,60,100,30)); pSumProxy->setGeometry(QRect(150,60,80,60)); pNumProxy->setParent(this); pPowProxy->setParent(this); pSumProxy->setParent(this); pSDiv->addItem(pNumProxy); pSDiv->addItem(pPowProxy); pSDiv->addItem(pSumProxy);
}@
what is the flicker reason for the code aboved
[Edit: Please wrap code in @ tags for proper formatting. -- mlong]
-
Are u using qt4?