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

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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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)

      saitejS 1 Reply Last reply
      0
      • mrjjM mrjj

        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)

        saitejS Offline
        saitejS Offline
        saitej
        wrote on 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

        mrjjM 1 Reply Last reply
        0
        • saitejS saitej

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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.

          saitejS 1 Reply Last reply
          1
          • mrjjM mrjj

            @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.

            saitejS Offline
            saitejS Offline
            saitej
            wrote on 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
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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.

              saitejS 1 Reply Last reply
              1
              • mrjjM mrjj

                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.

                saitejS Offline
                saitejS Offline
                saitej
                wrote on last edited by saitej
                #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
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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.

                  saitejS 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    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.

                    saitejS Offline
                    saitejS Offline
                    saitej
                    wrote on last edited by saitej
                    #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?

                    mrjjM 1 Reply Last reply
                    0
                    • saitejS saitej

                      @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?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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