PDA

View Full Version : QGroupBox frame



pippo42
15th January 2010, 13:17
Hello!

I have created a QGroupBox but there is no frame. I have looked in the documentation and tried several things but I cannot succeed in making the frame appear.

Thank you!

Here is the piece of code I have written:

QGridLayout *widgetLayout=new QGridLayout();
QGridLayout *groupBoxLayout=new QGridLayout();
QGroupBox *gb=new QGroupBox("test");
QLineEdit *le=new QLineEdit();
groupBoxLayout->addWidget(le,0,0);
gb->setLayout(groupBoxLayout);
layout->addWidget(gb,0,1);
setLayout(layout);

sudhansu
15th January 2010, 13:21
I faced same problem. used setStylesheet to customised the style sheet. N it worked.

pippo42
15th January 2010, 13:32
Thank you!

I try...

pippo42
15th January 2010, 13:56
It works... but it pushes the title downwards where it crashes onto the other widgets. I was trying to achieve the situation we see in every example where the title is on the line that is interrupted to let it appear.

pippo42
15th January 2010, 14:03
Now it works!
Thank you.

The solution is something like that:


groupBox->setStyleSheet("QGroupBox{border:2px solid gray;border-radius:5px;margin-top: 1ex;} QGroupBox::title{subcontrol-origin: margin;subcontrol-position:top center;padding:0 3px;}");