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. Wrong OpenGL viewport of widget inside QDockWidget
Qt 6.11 is out! See what's new in the release blog

Wrong OpenGL viewport of widget inside QDockWidget

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 705 Views 2 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.
  • Jaime02J Offline
    Jaime02J Offline
    Jaime02
    Qt Champion 2021
    wrote on last edited by Jaime02
    #1

    Hello. I am drawing stuff on a widget which is inside a QDockWidget and has a 1:1 squared aspect ratio. However, the drawing surface is not properly resized. When the size of the widget is equal to its size hint, the drawing is done properly:

    f5928192-c72e-4aa6-af6e-b53bf16cd5c0-image.png

    But when it is smaller or bigger, it is not properly drawn:

    1c8ce551-74f3-433d-acfc-d07e57b3c99f-image.png

    or

    453005e9-be1e-4475-bbc9-b5042038a92b-image.png

    Full source code: https://github.com/Jaime02/Dibujo-tecnico-Cpp

    resizeEvent (this keeps a 1:1 aspect ratio):

    void Renderer::resizeEvent(QResizeEvent *event){
        if (this->width() > this->height()){
            this->resize(this->height(), this->height());
        } else {
            this->resize(this->width(), this->width());
        }
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should add which version of Qt you are using as well as platform you run that code on.

      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
      • Jaime02J Offline
        Jaime02J Offline
        Jaime02
        Qt Champion 2021
        wrote on last edited by
        #3

        Hello. Thanks for answering ❤
        Qt version: 5.14.2 MinGW 64-bits
        Platform: Windows 10, updated.
        I have a Python version which works fine, but the c++ version does not.

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

          Does the python version use the same version of Qt ?

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

          Jaime02J 1 Reply Last reply
          0
          • SGaistS SGaist

            Does the python version use the same version of Qt ?

            Jaime02J Offline
            Jaime02J Offline
            Jaime02
            Qt Champion 2021
            wrote on last edited by
            #5

            @SGaist Yes it does
            a5c372fd-c16a-4759-b36a-371d6532ae3f-image.png

            1 Reply Last reply
            0
            • Jaime02J Offline
              Jaime02J Offline
              Jaime02
              Qt Champion 2021
              wrote on last edited by
              #6

              I have created a question here: https://stackoverflow.com/questions/62290688/wrong-opengl-viewport-of-widget-inside-qdockwidget I have included gifs and a Python MRE

              1 Reply Last reply
              0
              • Jaime02J Offline
                Jaime02J Offline
                Jaime02
                Qt Champion 2021
                wrote on last edited by
                #7

                I found the problem:
                There was missing a QOpenGLWidget::resizeEvent(event); statement at resizeEvent.

                1 Reply Last reply
                1

                • Login

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