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. QScrollArea with mixed content, how to scroll that no labels or QLineedits will be cut off?`
Forum Updated to NodeBB v4.3 + New Features

QScrollArea with mixed content, how to scroll that no labels or QLineedits will be cut off?`

Scheduled Pinned Locked Moved Unsolved General and Desktop
qscrollareacutembedded
9 Posts 3 Posters 3.7k 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.
  • B Offline
    B Offline
    BluTiGeS
    wrote on last edited by
    #1

    Hi all,

    i am currently working on a embedded solution which has a LCD attached + keypad.

    I have a Widget where the IP settings can be configured.
    The Widget has a QScrollArea which contains a Gridlayout with several Labels and regarding QLineEdits.

    The problem is now, if I move the focus (using keyboard) down or up, the labels and QLineEdits can be cut off at the beginning or the end of the scrollarea.

    I know this is normal windows behaviour, but how can I achieve it that the labels and the regarding QLineEdit will be always fully viewable without having them cut off?

    So target solution shall be if I scroll up/down the elements which are shown in the ScrollArea shall not be cut off.

    Is there some generic solution or idea how to achieve it?

    I already tried using offset and redrawing, but this will be a lot of effort for the widgets, so I am searching for a more generic and smarter solution.

    Many Thanks in advance

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

      @BluTiGeS said:

      Have you tried
      http://doc.qt.io/qt-5.5/qscrollarea.html#ensureWidgetVisible

      on the widget you wish to be fully visible?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BluTiGeS
        wrote on last edited by
        #3

        @mrjj
        Thank you for your reply, I tried:

        ui->scrollArea->ensureWidgetVisible( ui->label );

        but the label is still cut off, do I am using it wrong?
        The label which shall not be cut off is insige a gridlayout of the scrollarea.

        Many Thanks

        mrjjM 1 Reply Last reply
        0
        • B BluTiGeS

          @mrjj
          Thank you for your reply, I tried:

          ui->scrollArea->ensureWidgetVisible( ui->label );

          but the label is still cut off, do I am using it wrong?
          The label which shall not be cut off is insige a gridlayout of the scrollarea.

          Many Thanks

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

          @BluTiGeS
          Well I used it on a widget that hold the other elements.
          I added some y margin before i liked it fully.

          You must call it when you navigate. Like on keypress. then call it.
          Since I think you have more than one label,
          ensureWidgetVisible( ui->label );
          seems wrong?

          You can use event filter to catch changing focus
          QObject::installEventFilter()
          http://www.qtforum.org/article/2532/how-can-i-emit-a-signal-when-a-lineedit-is-focused.html

          Then ensureWidgetVisible.

          You cant just call it once.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BluTiGeS
            wrote on last edited by
            #5

            @mrjj
            Ahh okay I see, but this will not prevent the cut off of the other elements, but I am thinking if I go this way how to ensure that the previous label is also be shown?

            So if

            Some content
            Label
            Button

            is in the scrollara and the ensure is set to the button, how to make sure that the label before is also fully visible in combiantion with the button a line below?

            see:
            https://picload.org/image/pcwcrao/2015-11-2018_16_33-filmetv.png

            There the buttons are still cut off. It would be nice if the elements are always fully displayed and scrolled elementwise.

            The scrollarea height is fixed, so no resize possible on the target.

            Any idea for this issue?

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

              well you can maybe adjust scroll amount
              ui->scrollArea->verticalScrollBar()->setSingleStep(25);
              so it matches the height you want.
              so each scroll would scroll one "row" height being
              what ever u want.
              So the last one is never cut.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                BluTiGeS
                wrote on last edited by
                #7

                Settings the scrollheight would fit if the height is always the same.
                But how to get it Händler more dynammically if for example one "row" has a different height?

                I am really thinking about a generic solution for multiple pages/Widgets.

                So any help is appreciated also thanks for currently answers.

                Some further thougt s ;) how to get this done for different "row" heights?

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  BluTiGeS
                  wrote on last edited by
                  #8

                  Does anyone have a further solution or hint, how this could be achieved?
                  I cannot imagine this was never done with Qt ;).

                  Many Thanks

                  Regards

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi,

                    You can try to use ensureWidgetVisible by calling it if e.g. the scroll bar has not been moved for a certain amount of time.

                    Hope it helps

                    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

                    • Login

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