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. Scroll area is smaller than dialog

Scroll area is smaller than dialog

Scheduled Pinned Locked Moved General and Desktop
scrollarea
7 Posts 2 Posters 2.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.
  • G Offline
    G Offline
    gabor53
    wrote on 9 Feb 2016, 05:54 last edited by
    #1

    Hi,
    I have the following scroll area:

    QScrollArea *scroll = new QScrollArea(this);
        scroll->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
        scroll->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
        
        QWidget *viewport  = new QWidget(this);
        scroll->setWidget (viewport);
        scroll->setWidgetResizable (true);
    
    
        QFormLayout *layout = new QFormLayout(viewport);
        viewport->setLayout (layout);
        layout->setSpacing (60);
    
    
    
    // Title Row setup
        QHBoxLayout *titleRow = new QHBoxLayout(viewport);
        titleRow->addWidget (Title);
    
    //Creating the Name row
    
        QHBoxLayout *NameRow = new QHBoxLayout(viewport);
    
                    NameRow->addWidget (Label_Name);
                    NameRow->addWidget (LineEdit_Name);
                    NameRow->addSpacing (10);
                    NameRow->addWidget (angry_image_Label);
                    NameRow->addSpacing (10);
                    NameRow->addWidget (incorrect_Label);
            		NameRow->addSpacing (350);
    
    // Interspace
    
        layout->setVerticalSpacing (30);
    
        QLabel *spacer_Label = new QLabel;
    
    // Displaying the rows
    
        layout->addRow(titleRow);
        layout->addRow (spacer_Label,spacer_Label);
        layout->addRow (Label_ID,ID_Display);
        layout->addRow (NameRow);
    }
    

    It produces the following dialog:
    Image
    Please help me to find out why the scrolling area is smaller than the dialog.
    Thank you.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Ni.Sumi
      wrote on 9 Feb 2016, 09:32 last edited by Ni.Sumi 2 Sept 2016, 10:20
      #2

      Hi @gabor53

      Set Grid-layout in the Dialog. Make Gridlayout inside the Dialog for the Scrollarea.Roughly the design of widgets looks like this.

      Dialog ( gridlyout ( Scrollarea( layout( yourwidget's)))) .

      Add this..
      QGridLayout *sam = new QGridLayout;
      sam->addWidget(your scrollarea );
      Dialogname->setlayout(sam)

      1 Reply Last reply
      3
      • G Offline
        G Offline
        gabor53
        wrote on 9 Feb 2016, 14:39 last edited by
        #3

        Thank you. It worked well.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Ni.Sumi
          wrote on 9 Feb 2016, 18:01 last edited by
          #4

          Hi @gabor53

          Okay. Please set it as solved . :)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gabor53
            wrote on 10 Feb 2016, 04:28 last edited by
            #5

            Just an other related question: Do I need to worry about this message:

            "QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout"?
            Thank you.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Ni.Sumi
              wrote on 10 Feb 2016, 09:05 last edited by
              #6

              Hi @gabor53 ,

              Till it works fine..no problem :)

              Yes that warning is from the HLaoyuts in the viewport. Why you have need 2 HLayouts in the viewport? You can add "title row widget" in the "NameRow" QHBoxLayout. Or use QGridLaoyut with stretching.

              1 Reply Last reply
              1
              • G Offline
                G Offline
                gabor53
                wrote on 10 Feb 2016, 13:51 last edited by
                #7

                Thank you.

                1 Reply Last reply
                0

                5/7

                10 Feb 2016, 04:28

                • Login

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