Results 1 to 12 of 12

Thread: Image-based widgets showing is too slow in Qt 4.2.1

  1. #1
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Image-based widgets showing is too slow in Qt 4.2.1

    Hi!

    I developing the application with image-based widgets inherited from Qt abstract widgets.
    This mean that I use QPixmap for drawing backgrounds or active elements of this widgets (don't ask me why I don't used Qt styles )))

    But when I try to hide one frame with this kind of widgets and show another I have a unpleasant flash (when the frame is hiding) and slow redrawing of the frame which must be shown. More unpleasant that I use 1280 x 1024 resolution - may be bitmaps too big for create double buffering in 2D.

    How I can accelerate widget showing/hiding without using any hardware solutions?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Do you, by any chance, manipulate rendered images somehow during every paint event?
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Quote Originally Posted by jpn View Post
    Do you, by any chance, manipulate rendered images somehow during every paint event?
    I just repaint bitmaps without any transformations. For example:

    Qt Code:
    1. void Slider::paintEvent(QPaintEvent *)
    2. {
    3. QPainter painter(this);
    4. QBrush brush(S_COLOR);
    5. QPen pen(S_COLOR);
    6.  
    7. painter.drawPixmap(0, 0, *background);
    8. painter.setPen(pen);
    9. painter.setBrush(brush);
    10. painter.drawRect(xs, yd, is - xs, js - yd);
    11. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Try increasing the pixmap cache, with QPixmapCache::setCacheLimit(int).
    If I remember correctly you have to pass a number of kilobytes there. An 1280*1024 pixmap will automatically not be cached since the initial limit is 1Mb.

    Next, maybe you can make some use for QPaintEvent::rect and update only the dirty area.

    Regards

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Also take a look at optimizing with pixmap cache: http://doc.trolltech.com/qq/qq12-qpixmapcache.html.

    BTW, why don't you use tiles instead of really large images? tiles could be cached more easily.

    Regards

  6. The following user says thank you to marcel for this useful post:

    mkrentovskiy (8th August 2007)

  7. #6
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Quote Originally Posted by marcel View Post
    Try increasing the pixmap cache, with QPixmapCache::setCacheLimit(int).
    If I remember correctly you have to pass a number of kilobytes there. An 1280*1024 pixmap will automatically not be cached since the initial limit is 1Mb.
    I increased cache limit up to 32Mb but flash in show/hide-operations still going on. But redrawing is a faster subjective.

    Quote Originally Posted by marcel View Post
    Next, maybe you can make some use for QPaintEvent::rect and update only the dirty area.
    Its right but not for total widget repainting when all visible area are dirty.

  8. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Its right but not for total widget repainting when all visible area are dirty.
    Yes, but at least you can get faster updates for smaller dirty areas.

    Regards

  9. #8
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Quote Originally Posted by marcel View Post
    Yes, but at least you can get faster updates for smaller dirty areas.
    I agree with you, but in this case application will be shown over any window (for touchscreen purposes).

  10. #9
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Marcel, thank you for link.

    Quote Originally Posted by marcel View Post
    BTW, why don't you use tiles instead of really large images? tiles could be cached more easily.
    What is it? Where I can read about it?

  11. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Well, not sure where you can read about it.
    Tiles means splitting the bigger image into smaller rectangles(tiles) and draw them in the paint event.

    Although, now that you said that your app is always on top, not sure how is this going to help you.

    Maybe drawing is faster if you use a graphics view or a gl widget? But I don't know if that suites you.

    Regards

  12. #11
    Join Date
    Aug 2007
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Quote Originally Posted by marcel View Post
    Maybe drawing is faster if you use a graphics view or a gl widget? But I don't know if that suites you.
    Ok, I try to experimented with it. Thanks for your help.

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image-based widgets showing is too slow in Qt 4.2.1

    Quote Originally Posted by mkrentovskiy View Post
    I agree with you, but in this case application will be shown over any window (for touchscreen purposes).
    That doesn't mean anything. If you have a widget that contains a button and you push that button, the parent widget will probably receive a paint event as well for the rectangle that contains the push button. So partial paint events may still occur.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.