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
Forum Updated to NodeBB v4.3 + New Features

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 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
    • Ni.SumiN Offline
      Ni.SumiN Offline
      Ni.Sumi
      wrote on last edited by Ni.Sumi
      #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 last edited by
        #3

        Thank you. It worked well.

        1 Reply Last reply
        0
        • Ni.SumiN Offline
          Ni.SumiN Offline
          Ni.Sumi
          wrote on last edited by
          #4

          Hi @gabor53

          Okay. Please set it as solved . :)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gabor53
            wrote on 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
            • Ni.SumiN Offline
              Ni.SumiN Offline
              Ni.Sumi
              wrote on 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 last edited by
                #7

                Thank you.

                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