Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QT Qsplitter disable scrollbar on resizing QLabel

    General and Desktop
    qt5.10 c++ qt scrollarea qlabel
    2
    9
    2759
    Loading More Posts
    • 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
      magicstar last edited by magicstar

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • M
          magicstar @SGaist last edited by

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • M
              magicstar @SGaist last edited by magicstar

              @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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • M
                  magicstar @SGaist last edited by magicstar

                  @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 Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • M
                      magicstar @SGaist last edited by

                      @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 Reply Quote 0
                      • First post
                        Last post