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. Use QOpenGLWigdet in QGraphicsView, display will be displayed after hiding, update will not refresh
Forum Updated to NodeBB v4.3 + New Features

Use QOpenGLWigdet in QGraphicsView, display will be displayed after hiding, update will not refresh

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 480 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.
  • D Offline
    D Offline
    David Tang
    wrote on last edited by
    #1

    The following is the constructor code that inherits the QGraphicsView class, using QOpenGLWidget:

    M_scene = new QGraphicsScene( this );
    setScene( m_scene );
    setViewport(new QOpenGLWidget(this));

    Call setHidden(true) in other Widgets, and then set to false, call update will not refresh

    It is normal to not use opengl.

    //setViewport(new QOpenGLWidget(this));

    This problem will also appear on the PC and Android platforms, please help confirm what is the reason. Thank you!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What version of Qt are you using ?
      What exact OS version are you running your application from ?
      Can you provide a minimal compilable example that shows that behaviour ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        David Tang
        wrote on last edited by
        #3

        Qt 5.12.2 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2017) on "windows"

        OS: Windows 7 SP 1 (6.1) [winnt version 6.1.7601]

        I am using an open source project, qflightinstruments-20180421, just modified to opengl way, I provide the entire project directly.

        [0_1558000009369_src.zip](Uploading 100%)

        In line 102 of qfi_PFD.cpp, setViewport uses openGLWidget, the following is part of the code

        qfi_PFD::qfi_PFD( QWidget * parent ) :
            QGraphicsView ( parent ),
        ......
        {
            Reset();

        M_scene = new QGraphicsScene( this );
            setScene( m_scene );

        //use openGLwidget
            setViewport(new QOpenGLWidget(this));

        M_scene->clear();

        ......

        Init();
        }

        In the 213 line of MainWindow.cpp, the update display, hidden and displayed in 222 lines per second, the following is part of the code

        Void MainWindow::timerEvent( QTimerEvent *event )
        {
            /////////////////////////////////////
            QMainWindow::timerEvent( event );
            /////////////////////////////////////

        ......

        M_ui->widgetPFD->update();

        Qint64 time2 = QDateTime::currentMSecsSinceEpoch();
            If( time2 - m_time1 > 1000 )
            {
                qDebug()<<m_time1<<time2<<m_steps;
                M_time1 = time2;
                M_steps = 0;
                M_ui->widgetPFD->setTestHidden();

        }

        The following are hidden and show functions
            Inline void setTestHidden()
            {
                setHidden(!isHidden());
            }

        jsulmJ 1 Reply Last reply
        0
        • D David Tang

          Qt 5.12.2 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2017) on "windows"

          OS: Windows 7 SP 1 (6.1) [winnt version 6.1.7601]

          I am using an open source project, qflightinstruments-20180421, just modified to opengl way, I provide the entire project directly.

          [0_1558000009369_src.zip](Uploading 100%)

          In line 102 of qfi_PFD.cpp, setViewport uses openGLWidget, the following is part of the code

          qfi_PFD::qfi_PFD( QWidget * parent ) :
              QGraphicsView ( parent ),
          ......
          {
              Reset();

          M_scene = new QGraphicsScene( this );
              setScene( m_scene );

          //use openGLwidget
              setViewport(new QOpenGLWidget(this));

          M_scene->clear();

          ......

          Init();
          }

          In the 213 line of MainWindow.cpp, the update display, hidden and displayed in 222 lines per second, the following is part of the code

          Void MainWindow::timerEvent( QTimerEvent *event )
          {
              /////////////////////////////////////
              QMainWindow::timerEvent( event );
              /////////////////////////////////////

          ......

          M_ui->widgetPFD->update();

          Qint64 time2 = QDateTime::currentMSecsSinceEpoch();
              If( time2 - m_time1 > 1000 )
              {
                  qDebug()<<m_time1<<time2<<m_steps;
                  M_time1 = time2;
                  M_steps = 0;
                  M_ui->widgetPFD->setTestHidden();

          }

          The following are hidden and show functions
              Inline void setTestHidden()
              {
                  setHidden(!isHidden());
              }

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @David-Tang You can't upload files here.
          Upload it to some file sharing service and put the link here.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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