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. Help with aligning child widgets in parent widget

Help with aligning child widgets in parent widget

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.4k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    holygirl
    wrote on last edited by
    #1

    Hey everybody!

            I have a _mainwindow_ which is used to contain several other widgets. I use _QVBoxLayout_ and _QHBoxLayout_ to align these widgets in the _mainwindow_ as,
    

    @
    NewWidget *nw = new NewWidget();
    NewWidgetTwo *nwt = new NewWidgetTwo();
    NewWidgetThree *nwth = new NewWidgetThree();

    QHboxLayout *hbl = new QHBoxLayout();
    QVboxLayout *vbl = new QVBoxLayout();
    
    hbl->addWidget(nw);
    hbl->addWidget(nwt);
    
    vbl->addWidget(nwth);
    vbl->addLayout(hbl);
    

    @

    I tried using the stretch property and also the alignment options in Qt like Qt::AlignLeft, Qt::AlignLeading etc but I'm not able to achieve the desired alignment. Are there any other ways in Qt to position widgets?
    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      bq. I’m not able to achieve the desired alignment

      Can you attach an image of your requirement as well as the output you are getting now. You can also use a gridlayout

      @QGridLayout *gd1 = new QGridLayout();
      gd1->addWidget(nw,0,0,1,1);
      gd1->addWidget(nwt,0,1,1,1);
      gd1->addWidget(nwth,1,0,1,2);@

      1 Reply Last reply
      0
      • H Offline
        H Offline
        holygirl
        wrote on last edited by
        #3

        I'm not allowed to attach a screenshot so I just made a mock up of how it should look and what the actual output is. Each red rectangle represents a widget and the blue rectangle is an image within the widget.

        EDIT: Okay I'm not able to upload a picture from my computer. Could somebody tell me how to do this?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Just put your image at some public location, and use its URL. I use my public dropbox folder for this, but there are plenty of other options. You cannot upload images to this forum directly.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            holygirl
            wrote on last edited by
            #5

            Grr! My office does not have access to dropbox, Google drive etc. I'll upload the picture when I'm at home. Thanks so much Andre :)

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #6

              Hi!
              Maybe some of this hostings are accesseble for your office:
              "http://postimage.org/":http://postimage.org/
              "http://www.freeimagehosting.net/":http://www.freeimagehosting.net/
              "http://imageshack.us/":http://imageshack.us/
              "http://ipicture.ru/":http://ipicture.ru/

              1 Reply Last reply
              0
              • H Offline
                H Offline
                holygirl
                wrote on last edited by
                #7

                Haha! It's funny how I clicked on each one of these links and it kept showing "Content blocked by your organization" :)
                My internet is down at home. I'll upload the file soon. Sorry!

                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