Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QOpenGlWidget format resetting when calling show()

    General and Desktop
    3
    5
    77
    Loading More Posts
    • 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.
    • J
      johansson_gbg last edited by

      Hi !

      I have noticed that pushing in QSurfaceFormat settings to my QOpenGlWidget gets resetted after i call show() on it. Is there a reason why this occurs and how do i prevent it?

          QSurfaceFormat glFormat;
          glFormat.setVersion(4, 5);
          glFormat.setProfile(QSurfaceFormat::CoreProfile);
          glFormat.setSamples(4); //anti aliasing
          QSurfaceFormat::setDefaultFormat(glFormat);
      
          QApplication qapp(argc, argv);
      
          QOpenGLWidget* openGlWidget = new QOpenGLWidget();
      
          openGlWidget->setFormat(glFormat);
      
          openGlWidget->show();
      
          QSurfaceFormat format1 = openGlWidget->format();
      
          std::cout << format1.samples() << std::endl; //samples == 0 here, not 4
      
          return qapp.exec();
      
      1 Reply Last reply Reply Quote 1
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Are you sure it is ?
        The call to show does not in fact show anything, it schedules a show event that will be processed by the event loop. Thus, your widget will not be shown until after app.exec() started.

        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 Reply Quote 0
        • J
          johansson_gbg last edited by

          Hi!

          I'm ofcourse not 100 % sure, i checked the source code and couldnt see that the method does apply anything on the QSurfaceFormat settings. However, i checked the value on the SurfaceFormat before and after the show() and it does indeed change at this method specifically. Any other source of reason why this is occuring? Why does the settings reset at all? How do i prevent it?

          Regards Dan

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            That's my point: you do it too early. Call it after the widget has actually been shown. As I wrote before, calling show just schedule the widget to appear, it does not make it appear.

            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 Reply Quote 0
            • M
              maruker last edited by

              Hi, I can't get anti-aliasing to work on QOpenGlWidget either and I noticed the exact same thing:
              The value of samples() is correct initially but gets reset.

              Since this thread also shows up on Google, I would like to ask if someone found a solution

              1 Reply Last reply Reply Quote 0
              • First post
                Last post