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. flickering when hiding and showing widget
Qt 6.11 is out! See what's new in the release blog

flickering when hiding and showing widget

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 2.0k Views
  • 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.
  • O Offline
    O Offline
    OtisLin
    wrote on last edited by
    #1

    I put a button and label in a widget, when I set visible to the widget, I will got same problem with this https://stackoverflow.com/questions/37640286/avoid-flickering-when-hiding-and-showing-widget.
    It is have better way to solve this problem?

    qt version : 5.9.5

    jsulmJ 1 Reply Last reply
    0
    • O OtisLin

      I put a button and label in a widget, when I set visible to the widget, I will got same problem with this https://stackoverflow.com/questions/37640286/avoid-flickering-when-hiding-and-showing-widget.
      It is have better way to solve this problem?

      qt version : 5.9.5

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @OtisLin I don't know what your use case exactly is, but did you consider to use https://doc.qt.io/qt-5/qstackedwidget.html ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • O Offline
        O Offline
        OtisLin
        wrote on last edited by
        #3

        Thanks your reply.
        螢幕快照 2020-02-07 下午2.04.15.png
        My question like this. Button_A will set area C visible false. add Button_B will set area C visible true.
        When the area C hidding and showing some times have flickering.

        It's look like layout problem. But still not found the key point. Maybe the QStackedWidget is the best way.

        1 Reply Last reply
        0
        • AndeolA Offline
          AndeolA Offline
          Andeol
          wrote on last edited by
          #4

          How is the connection between your buttons and the slots made ? This kind of issue often arises when there are several updates instead of one, which may be the case if A and B are grouped to be mutually exclusive. Do you use QPushButton::pressed or QPushButton::toggled ? It might be just because you simplified your issue to provide a minimal exemple, but it looks like you are using two buttons when you only need one (with a checked/unchecked state).

          Can you put some debug code in your "setVisible" slot, to check if it's called only once each time ?
          Does you still have that flickering is you put a breakpoint in the setVisible slot ?

          Last check : how is your layout made ? I guess C is a large widget that is inside a QVBoxLayout ? What happens when C is not visible ? Do A and B get lower, or is there a large bottom margin ? You may need a addStrech() at the end of your layout, if it's not already there.

          Developer for R++ : https://rplusplus.com/

          O 1 Reply Last reply
          0
          • AndeolA Andeol

            How is the connection between your buttons and the slots made ? This kind of issue often arises when there are several updates instead of one, which may be the case if A and B are grouped to be mutually exclusive. Do you use QPushButton::pressed or QPushButton::toggled ? It might be just because you simplified your issue to provide a minimal exemple, but it looks like you are using two buttons when you only need one (with a checked/unchecked state).

            Can you put some debug code in your "setVisible" slot, to check if it's called only once each time ?
            Does you still have that flickering is you put a breakpoint in the setVisible slot ?

            Last check : how is your layout made ? I guess C is a large widget that is inside a QVBoxLayout ? What happens when C is not visible ? Do A and B get lower, or is there a large bottom margin ? You may need a addStrech() at the end of your layout, if it's not already there.

            O Offline
            O Offline
            OtisLin
            wrote on last edited by
            #5

            @Andeol
            Thanks for your reply.
            When widgetC visible false. A and B will keep on top.
            Final I add a Spacer on the end. It's work.
            But as you said the maybe button call more than once. I will check this way.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved