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. QT Qsplitter disable scrollbar on resizing QLabel
QtWS25 Last Chance

QT Qsplitter disable scrollbar on resizing QLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.10c++ qtscrollareaqlabel
9 Posts 2 Posters 3.5k 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.
  • M Offline
    M Offline
    magicstar
    wrote on 29 Jan 2018, 14:09 last edited by magicstar
    #1

    I have added 2 QScrollArea-> QLabel in QSplitter. And am displaying video on both of them. And by default, both of them have same size..

    So, when I increase the size of one QLabel by adjusting QSplitter handle, the video takes new allocated space and scales accordingly. However, if I then decrease the size of QLabel, the video would still show up at previous bigger scale and scrollbars would appear.

    I instead want to display video without scrollbars and with whatever scale factor that fits current size.

    How this can be achieved ? Many thanks in advance!!!

    0_1517235044586_Untitled.png
    This is my code for displaying image on QLabel

    multiews[0] = ui->QImageLabel_view0;
    multiews[1] = ui->QImageLabel_view1;
    multiews[image_view]->setPixmap(QPixmap::fromImage(qImg).scaled(multiews[image_view]->width(),multiews[image_view]->height(),Qt::KeepAspectRatio));

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Jan 2018, 15:22 last edited by
      #2

      Hi and welcome to devnet,

      Why are you putting your labels in QScrollArea rather than ni the QSplitter directly ?

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

      M 1 Reply Last reply 29 Jan 2018, 15:42
      0
      • S SGaist
        29 Jan 2018, 15:22

        Hi and welcome to devnet,

        Why are you putting your labels in QScrollArea rather than ni the QSplitter directly ?

        M Offline
        M Offline
        magicstar
        wrote on 29 Jan 2018, 15:42 last edited by
        #3

        @SGaist
        I want scroll bars to show up when am zooming in/zooming out image.
        However, when am resizing window by QSplitter handle, I would like video to show up in fittocontents.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Jan 2018, 23:10 last edited by
          #4

          Then you have to modify your QScrollArea settings while dragging. See widgetResizable

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

          M 1 Reply Last reply 30 Jan 2018, 03:02
          0
          • S SGaist
            29 Jan 2018, 23:10

            Then you have to modify your QScrollArea settings while dragging. See widgetResizable

            M Offline
            M Offline
            magicstar
            wrote on 30 Jan 2018, 03:02 last edited by magicstar
            #5

            @SGaist
            Thanks a lot for your help.
            I tried your suggestion, Now I have

            void Dialog::on_splitter_2_splitterMoved(int pos, int index)
            {
            ui->scrollArea_2->setWidgetResizable(false);
            ui->QImageLabel_view0->resize(ui->scrollArea_2->size());
            }

            And I get desired behaviour only when am dragging splitter. However, scrollbars would again show up after releasing splitter handle.

            Could you please help me solve this weird behaviour.

            Also, may I know how can add ui->QImageLabel_view0->width() variable to watch while debugging. It may help solve the problem.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 30 Jan 2018, 07:50 last edited by
              #6

              What are you doing when you release the splitter ?

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

              M 1 Reply Last reply 30 Jan 2018, 08:07
              0
              • S SGaist
                30 Jan 2018, 07:50

                What are you doing when you release the splitter ?

                M Offline
                M Offline
                magicstar
                wrote on 30 Jan 2018, 08:07 last edited by magicstar
                #7

                @SGaist
                There is no signal for Qsplitter released.
                I am just refreshing Qlabel image view as shown above.
                The above function gets called when Qtimer timeouts.

                Update:
                I modified splitterMoved function as follows:
                void Dialog::on_splitter_2_splitterMoved(int pos, int index)
                {
                ui->scrollArea_2->setWidgetResizable(false);
                ui->QImageLabel_view0->setFixedSize(ui->scrollArea_2->size());
                ui->scrollAreaWidgetContents_2->setFixedSize(ui->scrollArea_2->size());
                width = multiews[0]->size().width();
                }
                Now am desired behaviour. The contents of image view would scale properly.
                However, scrollbars would still show up as shown below. And the extra space marked in red belongs to ui->scrollAreaWidgetContents_2.

                May I know how should I update its correctly ?
                0_1517328402993_Untitled.png

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 30 Jan 2018, 22:59 last edited by
                  #8

                  Resize the widget so that it doesn't require the scroll bar anymore.

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

                  M 1 Reply Last reply 31 Jan 2018, 13:40
                  0
                  • S SGaist
                    30 Jan 2018, 22:59

                    Resize the widget so that it doesn't require the scroll bar anymore.

                    M Offline
                    M Offline
                    magicstar
                    wrote on 31 Jan 2018, 13:40 last edited by
                    #9

                    @SGaist
                    I tried very hard. But, still am not satisfied with the implementation. And now am feeling helpless.
                    If I set set, fixedsize for QLabel, then scroll bars won't appear if I use zoomout/zoomin.
                    My question is why QLabel won't shrink back after changing size through Qsplitter. I tried all the combinations of sizepolicy and nothing has worked so far

                    1 Reply Last reply
                    0

                    7/9

                    30 Jan 2018, 08:07

                    • Login

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