Results 1 to 4 of 4

Thread: QLabel and setPixmap causes flickering

  1. #1
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLabel and setPixmap causes flickering

    Hello! I'm writing a simple wave editor. My current code of the waveform viewer is based on some steps:
    1. Prepare the QPixmap with the portion of the waveform (according to the scrollbar position).
    2. Use the generated pixmap with QLabel->setPixmap to show the picture.
    3. This code is connected with the QScrollBar::valueChanged signal.
    So I have the flickering on each valueChanged. The label quickly goes black, then my image is appear.
    Is there a cure or another way to draw pixmap without a blinking? If you interesting, you can look at the source code at http://eko.git.sourceforge.net/git/g...eko/eko;a=tree - the code of waveform redraw is in the document.cpp - CWaveEdit::draw_waveform function.

  2. #2
    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: QLabel and setPixmap causes flickering

    Your code is awfully slow as you are drawing on an image only to convert it to a pixmap. One thing to optimize is to draw immediately on a pixmap. Another is to redraw only this portion of the pixmap that actually needs redrawing. It would probably be a wise thing to have the whole wave pregenerated into a pixmap and only copy part of the rendering into another pixmap that will be set on the label (or simply use QScrollArea with the pregenerated pixmap set onto a label). This all should help but honestly your label shouldn't be going black regardless of the speed of your code. If it does, there is probably some logical error in the code causing a black pixmap to be created and rendered onto the label before the proper pixmap is generated.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default

    I'm render just a visible part of the waveform to avoid the full sound peaks calculation. So I think that the rendering of the whole waveform is more time consuming and memory consuming too.
    If I use the QPixmap directly, I get the image with some garbage/noise (partially overlapped the waveform).

    Update: all fixed! I use QImage::Format_RGB32 now and all works fine
    Last edited by wysota; 30th August 2010 at 10:40.

  4. #4
    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: QLabel and setPixmap causes flickering

    Quote Originally Posted by roxton View Post
    I'm render just a visible part of the waveform to avoid the full sound peaks calculation. So I think that the rendering of the whole waveform is more time consuming and memory consuming too.
    It depends whether it is a common task to scroll the wave back and forth. You either calculate the same things once or multiple times.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QLabel setPixmap doesnt work
    By arpspatel in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2010, 22:24
  2. QLabel setPixmap only works twice?
    By December in forum Qt Programming
    Replies: 0
    Last Post: 28th February 2010, 10:59
  3. qlabel can't use setPixmap() function
    By emailhy in forum Qt Programming
    Replies: 1
    Last Post: 24th December 2009, 23:30
  4. Replies: 2
    Last Post: 14th June 2007, 14:31
  5. QLabel not resize in setPixmap()
    By xgoan in forum Newbie
    Replies: 3
    Last Post: 23rd October 2006, 12:21

Tags for this Thread

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.