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. Understanding how Qt draws a GUI component ?
Forum Updated to NodeBB v4.3 + New Features

Understanding how Qt draws a GUI component ?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 2.5k 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.
  • C Offline
    C Offline
    Code Man
    wrote on 9 Jul 2014, 08:12 last edited by
    #1

    Hi , every one
    I heard that Qt now draws its GUI components fully natively , not like before (emulates them ) ,
    what I want to know is :
    The idea of how exactly Qt draw them natively in each platform ? is it just OS invoking (like someone in stackoverflow said) ?
    please, help me to understand the basic idea .

    Thanks :-)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 9 Jul 2014, 08:40 last edited by
      #2

      Qt is painting QtWidgets using QPainter, which uses (usually) the raster engine to draw the content. It is not using native OS calls, apart from few exceptions (file dialog, for example, which can be drawn either natively or using QtWidgets).

      QtQuick is painted using scenegraph, so OpenGL. Also, no native OS calls here.

      I think you either misunderstood (there are several meanings of the word "native" in computing) the stackoverflow post, or your information source is wrong.

      (Z(:^

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code Man
        wrote on 9 Jul 2014, 08:49 last edited by
        #3

        I posted this question in stackoverflow before. but someone said

        ( I'm pretty sure it just makes OS calls. It's up to the OS or not whether it's actually hardware accelerated. Other parts of Qt use OpenGL directly. – Ben Jul 5 at 8:07 )

        Now its clear :-)
        Thanks a lot.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 9 Jul 2014, 09:00 last edited by
          #4

          OK, then to be clear: by "native" I've meant using native OS controlls, like wxWidgets library does: asking the OS to draw native scroll bar, or combo box, etc. Qt does not do this. It paints all the widgets itself, and only tries to mimick the looks of the OS it is running on.

          But obviously, some kind of native OS calling is happening deep inside, in order to actually draw some pixels on the screen, and open native window container. But that is usually not important at all to high level UI developers.

          Contrary to what Ben Jul said, you have a clear choice whether the widget should be drawn by the CPU or the GPU: widgets can use different painting methods (native, raster, OpenGL, for more see "here":http://qt-project.org/doc/qt-5/qpaintengine.html#Type-enum), and the user has choice which one should be utilised. Most people do not use that, though, because the default settings work well.

          (Z(:^

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giordi
            wrote on 9 Jul 2014, 09:55 last edited by
            #5

            really interesting! thanks siederzio , is by default the cpu taking care of the draw?

            Coding is powaaaaa

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 9 Jul 2014, 11:01 last edited by
              #6

              For QtWidgets: yes.

              For QtQuick: no, OpenGL is the default.

              (Z(:^

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giordi
                wrote on 9 Jul 2014, 11:08 last edited by
                #7

                thanks a lot man, last question , if i am using widgets , and I am making a custom widged meaning overriding paint event.
                If I want to switch to opengl do I have to be carefull about something or opengl/qt handles everything manually under the hood?

                Coding is powaaaaa

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 9 Jul 2014, 11:23 last edited by
                  #8

                  Sorry, I am not experienced in this area enough to give you an answer.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giordi
                    wrote on 9 Jul 2014, 11:24 last edited by
                    #9

                    no problem , what I can do is just try to switch the painer in a cusatom widget and see what happen , maybe doing a bit of banckmark aswell

                    Coding is powaaaaa

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 9 Jul 2014, 22:12 last edited by
                      #10

                      Hi,

                      For mixing QPainter and OpenGL have a look at the Overpainting example

                      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

                      1/10

                      9 Jul 2014, 08:12

                      • Login

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