Reputation: 5968
I try programmatically set alignment of title of QGroupBox. According to the documentation I try to do it in the following way:
MainWidget::MainWidget (QWidget * parent)
: QWidget (parent)
{
setWindowTitle (tr ("QGropBox Title Alignment issue") );
QGroupBox * group = new QGroupBox ("Group Title", this);
QVBoxLayout * layoutTop = new QVBoxLayout ();
layoutTop->addWidget (group);
group->setAlignment (Qt::AlignHCenter);
this->setLayout (layoutTop);
}
But I have got unexpected result and title aligned with the left-hand side of the group box.
Such behaviour I have got with the environment:
The same behaviour I have got with the next environment:
But! If I use Qt installed from repository (Qt 5.4.2) the title will aligned with the centre by default. But if I change align to the left it will not changed.
I try find some solution with Google, but I haven't found similar questions and this is bad sign and usually this is means that I do some thing wrong.
So my question is: Why I can't manage by alignment of the group box title.
Upvotes: 0
Views: 2303
Reputation: 526
It seems like in Qt 5.5.1 there is a bug for some visual styles when QGroupBox title alignment is not taken into account when title's rect is computed: QTBUG-49068: QGroupBox title does not follow alignment with fusion style.
You can download most recent version from git repository, build it and check if the bug has been fixed (is has been for Fusion style: qt commit 139953).
If bug still occurs, I think you should submit an issue to Qt bugtracker.
Upvotes: 1