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. How to change swap intervals for QGLWidget
Forum Updated to NodeBB v4.3 + New Features

How to change swap intervals for QGLWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 694 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.
  • S Offline
    S Offline
    summit
    wrote on last edited by summit
    #1

    I am promoting a widet in UI to QGlWidget and in the constructor of QGLWidget i am assigning swap intervals to 0.

    But that does not affect the widget it still shows the value of swap interval as 1.

    How can i cahnge the swap value to 0.

    GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent)
    {
    QGLFormat format;
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSampleBuffers(true);
    format.setSamples(4);
    format.setSwapInterval(0);
    this->setFormat(format);
    makeCurrent();

    qDebug() << "Swap Interval +++++++++++++++++++++++++++++++++++++++   " << this->format().swapInterval();
    

    }

    I am on windows platform.

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    i also tried using QOpenglWidget and still was not able to change the Swap Interval , this is the code for QSurafaceFormat.

    int main(int argc, char *argv[])
    {
        QSurfaceFormat format;
        format.setDepthBufferSize(8);
        format.setStencilBufferSize(8);
    
        format.setRedBufferSize(8);
        format.setGreenBufferSize(8);
        format.setBlueBufferSize(8);
        format.setAlphaBufferSize(8);
        format.setSwapInterval(0);  //Turn Vsync on (1) / off (0)
        format.setProfile(QSurfaceFormat::CoreProfile);
        QSurfaceFormat::setDefaultFormat(format);
    
        //Make sure all OpenGL contexts share resources
        QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
        QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    
        const QSurfaceFormat& surfaceFormat = QSurfaceFormat::defaultFormat();
    
        
    
    
        QApplication a(argc, argv);
        QtWidgetsApplication2 w;
        w.show();
      
        return a.exec();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which version of Qt are you using ?
      By the way, QGLWidget is deprecated, it is advised to migrate to QOpenGLWidget.

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

      S 1 Reply Last reply
      0
      • S Offline
        S Offline
        summit
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Which version of Qt are you using ?
          By the way, QGLWidget is deprecated, it is advised to migrate to QOpenGLWidget.

          S Offline
          S Offline
          summit
          wrote on last edited by summit
          #4

          @SGaist Hi i am using 5.11 version , i also tried using QOpenGLWidget and changed the QSurafaceFormat swap interval to 0 but still it prints 1 as the value of swap interval.

          I have updated the code when using with QOpenGLWidget.

          Swap Interval just does not change and when i print the format in InitializeGL() function.
          qDebug() << this->format() << " THe format";

          I stillGet Swap Interval as 0.

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

            Can you check with a more recent version ? 5.11 is outdated.

            By the way, which platform are you on ?

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

            S 2 Replies Last reply
            0
            • SGaistS SGaist

              Can you check with a more recent version ? 5.11 is outdated.

              By the way, which platform are you on ?

              S Offline
              S Offline
              summit
              wrote on last edited by
              #6

              @SGaist i am on windows 10 , sure i will try with a newer version.

              1 Reply Last reply
              0
              • SGaistS SGaist

                Can you check with a more recent version ? 5.11 is outdated.

                By the way, which platform are you on ?

                S Offline
                S Offline
                summit
                wrote on last edited by
                #7

                @SGaist This same issue exists with the version 6.2.

                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