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. QFrame Sizing
QtWS25 Last Chance

QFrame Sizing

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 8.4k 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.
  • S Offline
    S Offline
    saitej
    wrote on 2 Jun 2016, 11:57 last edited by
    #1

    I have used QFrame and layouts to create a main window But the frames do not extend to the width/height of the mainwindow like in the image.

    How to make sure that the frame extends to the width of the mainwindow and also specify the height of a frame?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 2 Jun 2016, 12:00 last edited by
      #2

      Hi
      If u used layouts, then it should follow main window?
      OR in what way does it not work?

      Main window is special, so normally u insert a Central Widget, give it layout
      then insert all widget there. (into layout of central)

      S 1 Reply Last reply 2 Jun 2016, 12:15
      0
      • M mrjj
        2 Jun 2016, 12:00

        Hi
        If u used layouts, then it should follow main window?
        OR in what way does it not work?

        Main window is special, so normally u insert a Central Widget, give it layout
        then insert all widget there. (into layout of central)

        S Offline
        S Offline
        saitej
        wrote on 2 Jun 2016, 12:15 last edited by
        #3

        @mrjj
        But If I use a single layout, how can I group some widgets in to horizontal layout and somw widgets to vertical layout

        M 1 Reply Last reply 2 Jun 2016, 12:23
        0
        • S saitej
          2 Jun 2016, 12:15

          @mrjj
          But If I use a single layout, how can I group some widgets in to horizontal layout and somw widgets to vertical layout

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 2 Jun 2016, 12:23 last edited by
          #4

          @saitej

          well just like u did now?

          So you have
          Central widget ( just a dummy qwidget)
          Layout for central
          your master widget , (the one seen on picture)
          containing all your widget as seen on picture.

          If you need layout in layout, you can always
          insert Qwidget and use as place holder for other type of layout.

          S 1 Reply Last reply 2 Jun 2016, 12:29
          1
          • M mrjj
            2 Jun 2016, 12:23

            @saitej

            well just like u did now?

            So you have
            Central widget ( just a dummy qwidget)
            Layout for central
            your master widget , (the one seen on picture)
            containing all your widget as seen on picture.

            If you need layout in layout, you can always
            insert Qwidget and use as place holder for other type of layout.

            S Offline
            S Offline
            saitej
            wrote on 2 Jun 2016, 12:29 last edited by
            #5

            @mrjj

            Actually I have added widgets in different layouts and added these layouts in to different frames which I placed in the UI file. This might be the reason they are not extending to the end of the window. Any solution to set the frame size. (i have used only sizepolicy for each frame)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 2 Jun 2016, 12:38 last edited by
              #6

              Hi
              It sounds like u just need one extra layout to follow main win but talking about
              layouts is near to impossible.
              Also if any of the QFrames are
              just free floating then it wont scale.

              You can set min and max sizes on QFrames to adjust how they scale/resize.

              I need your project if to look at it. it not feasible to talk about as I have no idea what u put where etc.

              S 1 Reply Last reply 2 Jun 2016, 13:22
              1
              • M mrjj
                2 Jun 2016, 12:38

                Hi
                It sounds like u just need one extra layout to follow main win but talking about
                layouts is near to impossible.
                Also if any of the QFrames are
                just free floating then it wont scale.

                You can set min and max sizes on QFrames to adjust how they scale/resize.

                I need your project if to look at it. it not feasible to talk about as I have no idea what u put where etc.

                S Offline
                S Offline
                saitej
                wrote on 2 Jun 2016, 13:22 last edited by saitej 6 Feb 2016, 13:23
                #7

                @mrjj

                Mainwindow.cpp file

                QHBoxLayout *upperBarLayout = new QHBoxLayout;
                    QVBoxLayout *sideBarLayout = new QVBoxLayout;
                    QGridLayout *centralLayout = new QGridLayout;
                QGridLayout *bottomLayout = new QGridLayout();
                
                upperBarLayout->addWidget(widgetA);
                    upperBarLayout->addWidget(widgetB);
                 upperBarLayout->addWidget(widgetC);
                
                 ui->topframe->setLayout(upperBarLayout);
                    ui->topframe->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
                
                //sidebar
                    sideBarLayout->addWidget(widgetD,Qt::AlignTop);
                sideBarLayout->addWidget(widgetE,Qt::AlignTop);
                ui->sideframe->setLayout(sideBarLayout);
                    ui->sideframe->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
                //center frame
                centralLayout->addWidget(widgetF);
                ui->mainframe->setLayout(centralLayout);
                    ui->mainframe->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Fixed);
                //bottom
                
                    bottomLayout->addWidget(WidgetG);
                ui->bottomframe->setLayout(bottomLayout);
                    ui->bottomframe->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
                
                
                
                
                


                View the Mainwindo.UI

                The bottom frame is below the central frame. Hope this gives a better idea of my problem.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 2 Jun 2016, 14:32 last edited by
                  #8

                  hmm
                  centralLayout->addWidget(widgetF);
                  ui->mainframe->setLayout(centralLayout);

                  so widgetF should follow main win. ?

                  but it seems not all is inside widgetF .
                  so ui->topframe is not inside Central ?

                  Why didnt you make all in UI editor?
                  That way u can see at once if working.

                  S 1 Reply Last reply 3 Jun 2016, 06:26
                  1
                  • M mrjj
                    2 Jun 2016, 14:32

                    hmm
                    centralLayout->addWidget(widgetF);
                    ui->mainframe->setLayout(centralLayout);

                    so widgetF should follow main win. ?

                    but it seems not all is inside widgetF .
                    so ui->topframe is not inside Central ?

                    Why didnt you make all in UI editor?
                    That way u can see at once if working.

                    S Offline
                    S Offline
                    saitej
                    wrote on 3 Jun 2016, 06:26 last edited by saitej 6 Mar 2016, 06:27
                    #9

                    @mrjj

                    Thanks!! I have solved my problem by removing the frames and putting only layouts. Initially, the main window loads as I want with some space for another widget. I load a widget to this space through a slot then the entire window gets distorted. How to get it back to the original look? Is there a repaint function?

                    M 1 Reply Last reply 3 Jun 2016, 07:07
                    0
                    • S saitej
                      3 Jun 2016, 06:26

                      @mrjj

                      Thanks!! I have solved my problem by removing the frames and putting only layouts. Initially, the main window loads as I want with some space for another widget. I load a widget to this space through a slot then the entire window gets distorted. How to get it back to the original look? Is there a repaint function?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 3 Jun 2016, 07:07 last edited by
                      #10

                      @saitej
                      Hi
                      the layout will repaint them self if you add widgets.

                      If it becomes "strange" when you insert, its most likely
                      due to the layout altering the layout.'
                      Layout alter and controls the size of widgets so it might be some
                      side effect of you inserting.

                      1 Reply Last reply
                      0

                      1/10

                      2 Jun 2016, 11:57

                      • Login

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