Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:34:50+00:00 2026-06-16T21:34:50+00:00

I’m just a beginner and I wonder if it would be possible to create

  • 0

I’m just a beginner and I wonder if it would be possible to create a form widget on Mac like the info dialog in iTunes.

I tried using:

  • QGroupBox: I cannot find a way to get rid of the frames.
  • Creating my own widget: I cannot find a way to fix the spacing between the label and the QLineEdit widget using the QVBoxLayout (actually I’m not sure I understand well the differences between margin/spacing).
  • QFormLayout: I cannot find a way to reduce the size of the QLabel after using setrowWrapPolicy::WrapAllRows

Also I am not (yet) very comfortable with QtDesigner, so i’d like to avoir using it (for now)

Thanks in advance

Edit: Some precisions on the programs. I use QtCreator 2.6.1 with Qt 4.8.1 and 5.0 on Mac OS X Mountain Lion.

Edit 2: Here is the code.

Subclass of QWidget:

MCLineEdit::MCLineEdit(const QString &header)
{
    m_lineEdit = new QLineEdit;
    m_lineTitle = new QLabel(header);

    QVBoxLayout *layout = new QVBoxLayout;        
    layout->addWidget(m_lineTitle);
    layout->addWidget(m_lineEdit);
    layout->setSpacing(0);
    setLayout(layout);
}

To display the widget

myView::myView(QWidget *parent) :
QWidget(parent)
{
    setFixedSize(600, 500);
    MCLineEdit *lineEdit1 = new MCLineEdit("Test 1");
    MCLineEdit *lineEdit2 = new MCLineEdit("Test 2");
    MCLineEdit *lineEdit3 = new MCLineEdit("Test 3");
    MCLineEdit *lineEdit4 = new MCLineEdit("Test 4");

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(lineEdit1);
    mainLayout->addWidget(lineEdit2);
    mainLayout->addWidget(lineEdit3);
    mainLayout->addWidget(lineEdit4);
    mainLayout->setSpacing(0);

    setLayout(mainLayout);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:34:52+00:00Added an answer on June 16, 2026 at 9:34 pm

    This can be accomplished a ton of ways I am sure. Qt gives you all the possible layouts you could need to achieve this. You could do it with a QGridLayout, and add widgets with different amounts of “cell” spanning, and control the row and column sizes to suit. Or you can just do it with a bunch of nested vertical/horizontal layouts.

    For example, you can group a label and a field together in a QVBoxLayout, by adding the widgets with a left alignment, and then setting the spacing to 0 between the items:

    layout->setSpacing(0);
    layout->addWidget(aLabel, Qt::AlignLeft);
    layout->addWidget(aLineEdit, Qt::AlignLeft);
    
    mainVerticalLayout->addLayout(layout);
    

    For something like the track numbers, it is just more nested layouts:

    vLayout->addWidget(aLabel);
    hLayout->addWidget(aCheckbox);
    hLayout->addWidget(aLabel);
    hLayout->addWidget(aCheckbox);
    vLayout.addLayout(hLayout);
    

    And regarding your bullet points:

    1. QGroupBox lets you remove the frame with setFlat(bool)
    2. With layouts, the margin is the padding around the outside of the contained widgets. What you want is setSpacing(int) to control the amount of space between the items in the layout.
    3. QFormLayout is probably not your best choice here. That is usually for having labels on one side and widgets on the other. Basically it is a 2 column layout. A QGridLayout would be more appropriate. And to reduce the size of the QLabel, you can give it a max or a fix size. Such as using setFixedWidth() or setMaximumWidth() on the label.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.