Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Help me ,about the QGraphicsView ,it flicker always in my aplication
Forum Updated to NodeBB v4.3 + New Features

Help me ,about the QGraphicsView ,it flicker always in my aplication

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zhangjunhua
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gayu
      wrote on last edited by
      #2

      Are u using qt4?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved