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 are QPen and QBrush expencive?

How are QPen and QBrush expencive?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 494 Views
  • 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
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    Do QPen or QBrush contain some OpenGL resources?

    Does it make a sense to create them once before setting them in a loop?

    Can I do this

    painter->setPen(QPen(QColorConstants::Green));
    

    ?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Every allocation which you can avoid makes sense.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Every allocation which you can avoid makes sense.

        D Offline
        D Offline
        Dmitriano
        wrote on last edited by
        #3

        @Christian-Ehrlicher do they really allocate some resources? Or they are some structure like

        struct Brush { QColor color; ... };
        
        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • D Dmitriano

          @Christian-Ehrlicher do they really allocate some resources? Or they are some structure like

          struct Brush { QColor color; ... };
          
          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Dmitriano QPen and QBrush are classes as described in the documentation.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • D Dmitriano

            @Christian-Ehrlicher do they really allocate some resources? Or they are some structure like

            struct Brush { QColor color; ... };
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Dmitriano
            In addition to @Christian-Ehrlicher: don't forget that both of these are shared instance data, as per many Qt classes in https://doc.qt.io/qt-5/shared.html, so memory/resource usage may be less than you think.

            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