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. Repainting QScrollArea
Qt 6.11 is out! See what's new in the release blog

Repainting QScrollArea

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

    I have a horizontal QScrollArea, loaded with a QLabel.
    At some point I make changes to the QLabel and load it with shorter text.
    The problem is that after I load the shorter text, the horizontal scroll bar is still showing (although not needed). It's still showing, fitting the previous text length. Note that I see the text changed successfully, but the scroll bar isn't updated as expected.

    I tried the following as mentioned here:

    QScrollArea::update()
    QScrollArea::repaint()

    QScrollBar::update()
    QScrollBar::repaint()

    QScrollArea()::viewport()->update();
    QScrollArea()::viewport()->repaint();

    None of them worked.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlaaM
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Did you check that the size of the label changes after you set the text ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          Setting the widgetResizable property to true should do what you want. No need to call update or repaint. They mostly just invoke a paint event. They don't adjust sizes.

          1 Reply Last reply
          1
          • A Offline
            A Offline
            AlaaM
            wrote on last edited by
            #5

            @Moderators - It worked, thanks!

            1 Reply Last reply
            0

            • Login

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