Results 1 to 5 of 5

Thread: Performance problems with small pixmap

  1. #1
    Join Date
    Jan 2008
    Posts
    56
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Performance problems with small pixmap

    Hi all,

    I have a widget which contains among others a qwt_thermo element for displaying a signal level. On top of that, I placed a QLabel which contains a pixmap. This pixmap is a red LED turned off. When the signal level exceeds the desired range, I replace the pixmap with the one of a flashing LED.
    I update the signal levels every 20 miliseconds. As long as the signal pixmap is not switched, everything runs smoothly but as soon as the pixmap is changed, the thermo elements aren't running smoothly anymore (the LED is flashing correctly).
    I load the pixmaps in the constructor of the class, so they are just swapped when necessary.

    The thermo level is set in a slot and the pixmap is changed in a different slot.
    Should I use QueuedConnection, maybe?

    Are there any performance issues I am missing?
    Here, the simplified code:

    Qt Code:
    1. ...
    2. QPixmap* qpxRedLEDOff = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOff12x6.png"));
    3. QPixmap* qpxRedLEDOn = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOn12x6.png"));
    4. peakLimOn=false;
    5.  
    6. ledPeak = new QLabel();
    7. ...
    8.  
    9. void LevelWidget::setLevel(double l)
    10. {
    11. thermoLevel->setValue(l);
    12. }
    13.  
    14. void LevelWidget::switchPeakLED(bool on)
    15. {
    16. if (on!=peakLimOn)
    17. {
    18. peakLimOn=on;
    19. if (on)
    20. {
    21. ledPeak->setPixmap(*qpxRedLEDOn);
    22. }
    23. else
    24. {
    25. ledPeak->setPixmap(*qpxRedLEDOff);
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    Regards,

    Rainer

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Performance problems with small pixmap

    Are you sure that qpxRedLEDOff and qpxRedLEDOn from lines 2 & 3 are the same variables as the ones from lines 21 & 25? Do you use threads?

  3. #3
    Join Date
    Jan 2008
    Posts
    56
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance problems with small pixmap

    Hi jacek,

    thanks for your quick reply.

    Yes, pretty sure. The lines 2 & 3 are in the constructor of the class and the variables are declared in the header. I just wrote the declaration here for clarity.
    I use threads, but the updates of the qwt_thermo and the pixmap are done subsequently via direct call of the slots. No signals are used here.
    And the pixmap is only updated, if the value changes.
    Also, the pixmap is only 12x6 pixel big. There shouldn't be a performance issue.

    Could it be something with allocating the pixmaps on the heap / on the stack? Guess, that's not very probable.

    Regards,

    Rainer

  4. #4
    Join Date
    Jan 2008
    Posts
    56
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance problems with small pixmap

    Hi again,

    I am pretty clueless about that.
    I tried to add a static variable inside the function which sets the pixmap. That works, but still I have no fluid animation.
    Then, I thought that maybe the setPixmap triggers some "re-layout" of the whole thing, so I took the pixmap out of the layout and used fix coordinates.
    No changes.

    Could it be an issue with Qwt? Maybe I should post at the Qwt list.

    Regards,

    Rainer

  5. #5
    Join Date
    Jan 2008
    Posts
    56
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Performance problems with small pixmap

    Found it!

    Qt Code:
    1. ledPeak->setMinimumHeight(qpxRedLEDOff->height());
    2. ledPeak->setMinimumWidth(qpxRedLEDOff->width());
    3. ledPeak->setMaximumHeight(qpxRedLEDOff->height());
    4. ledPeak->setMaximumWidth(qpxRedLEDOff->width());
    To copy to clipboard, switch view to plain text mode 

    When I give the pixmaps fixed mins and maxs (in this case, these are the same values), the animation is fluid.
    If I leave out the fixed max or min setting, the animation is not fluid anymore.

    Regards,

    Rainer
    Last edited by jpn; 9th July 2008 at 17:05. Reason: missing [code] tags

Similar Threads

  1. Performance problems with overlapping qgraphicsitems
    By brjames in forum Qt Programming
    Replies: 13
    Last Post: 4th May 2008, 21:42
  2. QGraphicsScene/QGraphicsView performance problems
    By bnilsson in forum Qt Programming
    Replies: 71
    Last Post: 28th January 2008, 12:08
  3. GraphicsView performance problems
    By Gopala Krishna in forum Qt Programming
    Replies: 79
    Last Post: 8th August 2007, 17:32

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.