Results 1 to 2 of 2

Thread: Removing the flicker between widgets?

  1. #1
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Removing the flicker between widgets?

    Hi,

    I used the following concepts to display the incoming images scroll from left to right in the main window. The problem I have is there is a flicker between the images that occurs. How do i remove it? I tried using Qt:WA_PaintOnScreen , Qt:WA_NoSystemBackground attributes. But nothing changed.

    Qt Code:
    1. QScrollArea *scrollArea;
    2. //widget inside scroll area
    3. QWidget *scrollAreaWidgetContents;
    4. //Horizontal Box Layout
    5. QHBoxLayout *horizontalLayout;
    6. //Image loaded to find the width and height to resize the scroll area.
    7. QImage img(QString::fromUtf8("../../../Downloads/red_star.png"));
    8.  
    9. scrollArea = new QScrollArea(this->centralWidget());
    10. //Adding the size of the scrollbar with the image width
    11. int intWidth=img.width()*2.5+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
    12. //Adding the size of the scrollbar with the image Height
    13. int intHeight=img.height()+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
    14.  
    15. scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    16. //Sizing the scroll area and the inside widget
    17. scrollArea->setGeometry(QRect(0, 0,intWidth ,intHeight));
    18. scrollArea->setWidgetResizable(true);
    19. scrollAreaWidgetContents = new QWidget();
    20. scrollAreaWidgetContents->setGeometry(QRect(0, 0, intWidth, intHeight));
    21. Making the main window width to the scroll area width
    22. this->setFixedWidth(scrollArea->width());
    23. horizontalLayout = new QHBoxLayout(scrollAreaWidgetContents);
    24. scrollArea->setWidget(scrollAreaWidgetContents);
    25. //Image static array
    26. QString strImages[]= {"../../../Downloads/red_star.png","../../../Downloads/green_star.png","../../../Downloads/yellow_star.png"};
    27. //Add the image in the left side of the previous one (Note the color)
    28. for(int iCount=0; iCount<3; iCount++)
    29. {
    30. QLabel *label = new QLabel(QStringLiteral("label"),scrollAreaWidgetContents);
    31. label->setPixmap(QPixmap(strImages[iCount]));
    32. //Adding the new image to the left of previous image
    33. horizontalLayout->insertWidget(0,label);
    34. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Removing the flicker between widgets?

    A bunch of lines of code, with absolutely no information about how or where you are using those lines of code. There are lines in there (like #21) that aren't even real code. How should we know why you see flicker?

    If this is your actual code (with the incorrect lines commented out) and it is in the constructor, there is nothing in it that would cause flicker to occur. The images are loaded, the horizontal layout is set up, and then the whole thing is painted after a showEvent().

    What are you doing when you see flicker occur?

Similar Threads

  1. Replies: 8
    Last Post: 5th May 2021, 16:41
  2. Removing same type of Widgets from QWorkspace
    By zarkzervo in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2009, 09:53
  3. adding and removing widgets
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 30th November 2007, 01:34
  4. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 20:42
  5. Adding/removing widgets dynamically...
    By ReilenBlaeyze in forum Newbie
    Replies: 2
    Last Post: 16th February 2006, 10:55

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
  •  
Qt is a trademark of The Qt Company.