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. Qt 4.7.1 and QImage::convertToFormat
Forum Updated to NodeBB v4.3 + New Features

Qt 4.7.1 and QImage::convertToFormat

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 6.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
    CableGuy
    wrote on last edited by
    #1

    Hello,

    I'm quite new to Qt so please bear with me.
    My application uses Qt and stylesheets which causes a huge lag when switching between tabs.
    When removing the stylesheets everything seems to work fine.
    The thing is that I profilled the application and noticed that alot of the time is spent in QImage::convertToFormat.
    My guess is that this has to do with the fact that the styled GUI has lots of images, but still why does Qt has to call it each time?
    Also the function is not explicitly called by the application.
    So am I doing something wrong or is this normal behaviour?

    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I would imagine repeating calls to QImage::convertToFormat would be expensive, yes. It is weird that Qt would try converting the same images over and over again. That should happen only once, when needed, and the result should be cached.

      Would it be feasible for you to try to see what format your images are converted to, and see if you can adapt the format of your actual images to conform to that format? That might speed up your application then.

      In the meantime, I would file a "bug":http://bugreports.qt.nokia.com outlining the issue.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CableGuy
        wrote on last edited by
        #3

        AFAIK I can't see what format the images are converted to.
        Also I checked and when resizing the application this happens also
        which probably means that Qt is calling convertToFormat each time it has
        to repaint the widget.
        Any more help would be much appreciated.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You might be able to find out the format by setting a breakpoint in that method in QImage. That would allow you to inspect the format that was requested.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CableGuy
            wrote on last edited by
            #5

            Thanks, will do.
            Be back pronto.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              [quote author="CableGuy" date="1301562315"]Hello,
              My application uses Qt and stylesheets which causes a huge lag when switching between tabs.
              When removing the stylesheets everything seems to work fine.
              The thing is that I profilled the application and noticed that alot of the time is spent in QImage::convertToFormat.
              My guess is that this has to do with the fact that the styled GUI has lots of images, but still why does Qt has to call it each time?
              Also the function is not explicitly called by the application.
              So am I doing something wrong or is this normal behaviour?

              Thanks.[/quote]

              How did you build up your style sheet?
              What we found is that having huge style sheets (ours is about 4k lines) using together with many widgets (the test has about > 1000 widgets) gets slow during creation time. Runtime is ok.

              So here are my questions:

              do you (re)create the tabs while switching?

              Do you use huge style sheets on application level? Or only per widget?

              do you use stuff like border / background images in the style sheet?

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • C Offline
                C Offline
                CableGuy
                wrote on last edited by
                #7

                I can't seem to get my debugger to show the Qt source...
                I'll try creating a small test app and see what happens there.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  CableGuy
                  wrote on last edited by
                  #8
                  1. I'm not sure, I do hope not, but as mentioned this happens also when just resizing the window
                  2. I have quite a big stylesheet ~4.5K lines in it used in application level.
                  3. I don't know much about stylesheets but yes, there background images, border images.

                  I don't think the stylesheet itself is the cause but rather all the images/background images...

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    [quote author="CableGuy" date="1301569935"]I can't seem to get my debugger to show the Qt source...
                    I'll try creating a small test app and see what happens there.[/quote]

                    Are you linking against a debug version of Qt?

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      Using images in the style sheet could lead to new calculations on resizing, as the images need to be streched etc. This could be an issue. Especially as you said, without style sheet, you don't have those problems.

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        CableGuy
                        wrote on last edited by
                        #11

                        For what it's worth, further inverstigation showed that the execessive amount of QImage::convertToFormat calls
                        were caused by the usage of linear gradients and not images and after more googling, luanching the application
                        with -graphicssystem raster turned out to be a huge speed improvement. The question that still remains is why using the raster graphics system (which AFAIK is pure software) is faster that the usage of native X11?

                        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