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. FomLay out and its size
Forum Updated to NodeBB v4.3 + New Features

FomLay out and its size

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 738 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.
  • B Offline
    B Offline
    BinuJanardhanan
    wrote on last edited by
    #1

    I am using spinbox and label in each row of Form layout.
    I resized the spinbox. and add it to the form layout.
    but the size of the form layout is not equal to the widgets in it.

    below code, i have used.

    m_spinFreq= new QSpinBox();
       m_spinFreq->setFixedSize(QSize(100,35));
       m_spinPhase= new QSpinBox();
       m_spinPhase->setFixedSize(QSize(100,35));
       m_spinTE= new QSpinBox();
       m_spinTE->setFixedSize(QSize(100,35));
       m_spinTR= new QSpinBox();
       m_spinTR->setFixedSize(QSize(100,35));
    m_labFreq->setText("Freq");
       m_labPhase= new QLabel();
       m_labPhase->setText("Phase");
       m_labTE= new QLabel();
       m_labTE->setText("TE (ms)");
       m_labTR= new QLabel();
       m_labTR->setText("TR (ms)");
    m_formLayBasicOne=new QFormLayout();
    m_formLayBasicOne->setSpacing(30);  
    
       m_formLayBasicOne->setLabelAlignment(Qt::AlignVCenter);
       m_formLayBasicOne->addRow(m_labFreq,m_spinFreq);
       m_formLayBasicOne->addRow(m_labPhase,m_spinPhase);
       m_formLayBasicOne->addRow(m_labTE,m_spinTE);
       m_formLayBasicOne->addRow(m_labTR,m_spinTR);
       m_formLayBasicOne->setSpacing(30);
    this->setLayout(m_formLayBasicOne);
    

    Output

    0_1500013841485_251be404-e059-4ce5-aab7-6927490b20ec-Untitled.jpg

    I want to fix the layout size to its widget. ?
    Here widget in form layout occupied less space but too much free space is there. how can I avoid free space of right and bottom?

    raven-worxR 1 Reply Last reply
    0
    • Vinod KuntojiV Offline
      Vinod KuntojiV Offline
      Vinod Kuntoji
      wrote on last edited by
      #2

      @BinuJanardhanan ,

      You are calling setSpacing twice. Set some minimum size to your main widget.

      C++, Qt, Qt Quick Developer,
      PthinkS, Bangalore

      1 Reply Last reply
      0
      • B BinuJanardhanan

        I am using spinbox and label in each row of Form layout.
        I resized the spinbox. and add it to the form layout.
        but the size of the form layout is not equal to the widgets in it.

        below code, i have used.

        m_spinFreq= new QSpinBox();
           m_spinFreq->setFixedSize(QSize(100,35));
           m_spinPhase= new QSpinBox();
           m_spinPhase->setFixedSize(QSize(100,35));
           m_spinTE= new QSpinBox();
           m_spinTE->setFixedSize(QSize(100,35));
           m_spinTR= new QSpinBox();
           m_spinTR->setFixedSize(QSize(100,35));
        m_labFreq->setText("Freq");
           m_labPhase= new QLabel();
           m_labPhase->setText("Phase");
           m_labTE= new QLabel();
           m_labTE->setText("TE (ms)");
           m_labTR= new QLabel();
           m_labTR->setText("TR (ms)");
        m_formLayBasicOne=new QFormLayout();
        m_formLayBasicOne->setSpacing(30);  
        
           m_formLayBasicOne->setLabelAlignment(Qt::AlignVCenter);
           m_formLayBasicOne->addRow(m_labFreq,m_spinFreq);
           m_formLayBasicOne->addRow(m_labPhase,m_spinPhase);
           m_formLayBasicOne->addRow(m_labTE,m_spinTE);
           m_formLayBasicOne->addRow(m_labTR,m_spinTR);
           m_formLayBasicOne->setSpacing(30);
        this->setLayout(m_formLayBasicOne);
        

        Output

        0_1500013841485_251be404-e059-4ce5-aab7-6927490b20ec-Untitled.jpg

        I want to fix the layout size to its widget. ?
        Here widget in form layout occupied less space but too much free space is there. how can I avoid free space of right and bottom?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @BinuJanardhanan said in FomLay out and its size:

        Here widget in form layout occupied less space but too much free space is there. how can I avoid free space of right and bottom?

        widgetWithFormLayout->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
        

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1

        • Login

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