QGroupBox Title in Fusion setStyle
-
Hello,
I was wondering if there's an easy way to update the way to update the QGroupBox Title to be embedded in the border instead of above the QGroupBox in the Fusion QStyle?
So basically in the example the title is above the border which is what I don't want :

which I found here : https://doc.qt.io/qt-5/qtwidgets-widgets-groupbox-example.html
What I'm looking for is :

Which I found here in the QT5 class descriptor for QGroupBox : https://doc.qt.io/qt-5/qgroupbox.html
I've been messing around with title but not sure what dictates where the title actually lands.
QGroupBox::title {
subcontrol-origin: margin
left: 7px;
padding: 0px 5px 0px 5px;
}Sort of new to QT5 GUI Development. I've tried reading a style sheet (.qss file) and updating various attributes with no luck. And also tried setting the style to "Windows" which got me the proper box title alignment in the border but the whole look is old and not the look I'm going for. Really like Fusion (defaulted) but didn't know how to get the title to properly align with the border.
Any help would be appreciated!
-
Use https://doc.qt.io/qt-6/qgroupbox.html#alignment-prop and set Qt::AlignVCenter in Qt6
-
Use https://doc.qt.io/qt-6/qgroupbox.html#alignment-prop and set Qt::AlignVCenter in Qt6
@Christian-Ehrlicher thank you for the suggestion. I apologize I wasn't able to post the code but I'm on this air-gapped system that didn't make that easy. I did look into the alignment option but all I could do was move the title around that was still above the border. I could never get it to move into the border as I showed in the example above.
What I did end up doing was changing the QGroupBox::title reading in .qss file and playing around with the padding, top and left attributes:
QgroupBox::title {
subcontrol-origin: margin;
top: 10px;
left: 7px;
padding: 0px 5px 5px 5px;
}Which ended up giving me the look I was going over.
I appreciate the feed back! Thank you
-
K Kchan has marked this topic as solved on
-
The support for VCenter was added somewhere in Qt6.x
-
The support for VCenter was added somewhere in Qt6.x
@Christian-Ehrlicher I should have mentioned as well that we're stuck using QT5 for the time being.