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. QGridLayout Resizing
QtWS25 Last Chance

QGridLayout Resizing

Scheduled Pinned Locked Moved Solved General and Desktop
5.10.1qwidgetqgridlayout
6 Posts 2 Posters 3.0k 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.
  • E Offline
    E Offline
    ed-wright
    wrote on 5 Jul 2018, 15:43 last edited by ed-wright 7 May 2018, 15:44
    #1

    Hi Forum,

    I have a window that has the following layout.

    0_1530805242961_rtpstream.PNG

    The black boxes are QLabels that are pixmaps of QImages. They are contained within a QGridLayout. I want to be able to click on one of the black boxes and have it become the only blackbox, filling the entire window, and once it is clicked again, return to the multiple view layout. What is the best approach?

    I hope this is enough info. (I am on qt 5.10.1)

    Kind Regards

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Jul 2018, 20:39 last edited by
      #2

      Hi,

      One quick way would be to use a QStackedWidget or QStackedLayout with a QLabel in addition of your grid and on click you change the index and update the content of the label with the image you just clicked on.

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

      E 1 Reply Last reply 9 Jul 2018, 07:19
      2
      • S SGaist
        5 Jul 2018, 20:39

        Hi,

        One quick way would be to use a QStackedWidget or QStackedLayout with a QLabel in addition of your grid and on click you change the index and update the content of the label with the image you just clicked on.

        E Offline
        E Offline
        ed-wright
        wrote on 9 Jul 2018, 07:19 last edited by
        #3

        @SGaist

        Thanks for your reply, this looks good, although it there any Qt Widget that provides a stack of widgets where multiple widgets are visible at a time.

        Thanks in Advance

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Jul 2018, 21:42 last edited by
          #4

          What do you mean by multiple widgets ?

          QStackedWidget and QStackedLayout can contain complex widgets. As show in the documentation, they are just stored on top of each other. What the "contained" widgets contain can be anything you need.

          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
          1
          • E Offline
            E Offline
            ed-wright
            wrote on 10 Jul 2018, 09:40 last edited by
            #5

            @SGaist

            After going through the documentation i now have an implementation with that is 6 QStackedLayouts which contain the QPushButton and the QLabel that shows the image. Then the 6 QStackedLayouts are in a QGridLayout and this maintains the 3x2 layout that i was after.

            stackedLayout->setStackingMode(QStackedLayout::StackAll);
            

            This allowed me to see the label beneath the button (once i made the button transparent)

            If i wish to use the buttons to allow one of the QLabels to become full-screen what is the best way to recreate the layout as i cannot use setLayout(stackedLayout) twice. Should i do something along the lines of:

            Delete this->layout();
            setLayout(stackedLayout);
            

            Obviously this is not the correct solution but i am unsure how to proceed.

            Thanks Again

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 10 Jul 2018, 21:37 last edited by
              #6

              Why not implement my original suggestion ? Put a QLabel and your grid widget in a QStackedLayout and change to the label and back as needed ?

              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
              1

              1/6

              5 Jul 2018, 15:43

              • Login

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