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. Find out when a QScrollArea scrollbar is shown
Forum Updated to NodeBB v4.3 + New Features

Find out when a QScrollArea scrollbar is shown

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.9k Views 1 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.
  • R Offline
    R Offline
    reonZ
    wrote on last edited by reonZ
    #1

    I need to resize content inside a QScrollArea when the scrollbar is being shown due to ScrollBarAsNeeded policy, but there are no show or hide signals for QWidget nor did i find anything useful in QScrollBar or QAbstractSlider .

    What would be the procedure to do something like that ?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      Just thinking out loud, but what happens when you compare the size of the frame contained in the QScrollArea with the size of the QScrollArea itself? Does the child frame size() return its real size, or the visible size within the ScollArea? Test it and see...

      R 1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        If its visible, this seems to return the status fine
        qDebug() << "is there : " << ui->scrollArea->verticalScrollBar()->isVisible();

        R 1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          If its visible, this seems to return the status fine
          qDebug() << "is there : " << ui->scrollArea->verticalScrollBar()->isVisible();

          R Offline
          R Offline
          reonZ
          wrote on last edited by
          #4

          @mrjj I know i can test if it is visible, but it is not what i need here, i need to know when it become visible, to modify the values of some of the QWidget i have inside.

          1 Reply Last reply
          0
          • Kent-DorfmanK Kent-Dorfman

            Just thinking out loud, but what happens when you compare the size of the frame contained in the QScrollArea with the size of the QScrollArea itself? Does the child frame size() return its real size, or the visible size within the ScollArea? Test it and see...

            R Offline
            R Offline
            reonZ
            wrote on last edited by
            #5

            @Kent-Dorfman That is not an issue here, i can calculate the size of the area inside fine (that is already what i am doing), my problem is that sometimes there are no scrolbar and sometimes there is, when i calculate the size of my QWidget which is relative to the size of the inside area, i do it when i insert it, but by that point, the scrollbar is not there yet if it were to be.

            What i need is some kind of event that triggers when the scrollbar appears, so i can re-calculate everything.

            mrjjM 1 Reply Last reply
            0
            • R reonZ

              @Kent-Dorfman That is not an issue here, i can calculate the size of the area inside fine (that is already what i am doing), my problem is that sometimes there are no scrolbar and sometimes there is, when i calculate the size of my QWidget which is relative to the size of the inside area, i do it when i insert it, but by that point, the scrollbar is not there yet if it were to be.

              What i need is some kind of event that triggers when the scrollbar appears, so i can re-calculate everything.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @reonZ said in Find out when a QScrollArea scrollbar is shown:

              What i need is some kind of event that triggers when the scrollbar appears, so i can re-calculate everything.

              Well, you could use an eventfilter and watch for the showEvent for the scrollbar(s)

              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