PDA

View Full Version : QComboBox in QGroupBox header



SCambon
18th June 2018, 16:29
Hi everyone,

I'm new with Qt 5.11 and I can found a way to put a QComboBox or even an Icon in a QGroupBox header.
My objective is to allow the content to change according to the QComboBox selection and the icon is to display an information window about this content.
If someone has an idea fill free to help me.

Thanks in advance.

Ginsengelf
19th June 2018, 08:26
Hi, why not use a QComboBox and a QStackedWidget for the different contents? For the icon you can use a QLabel.

Ginsengelf

SCambon
19th June 2018, 14:32
Hi,

Thank you for your return.
Unfortunately QStackedWidget is only useful to manage the inside of the QGroupBox for example (to change the contain according to the selection in the QComboBox).
But what i'm currently trying to do is to put the QComboBox in the QGroupBox Header which only accept some text it seems.
Maybe I'm not clear. In fact when creating a QGroupBox you specify a title/header which appears in the top left of the QGroupBox (same level as the surrounding line).
I want to put a QComboBox in place of this text and even an icon if possible.

Have a good day.

d_stranz
19th June 2018, 16:11
Maybe you should consider that what you want to do cannot be done with QGroupBox.

Ginsengelf gave you an alternative way to make something with a similar appearance. If that isn't suitable, then you will have to write your own QWidget that looks like a group box but behaves the way you want it to.

SCambon
20th June 2018, 08:16
In fact I was almost sure that it was not possible (I read a large part of the documentation) but because I am new with Qt I was decided to ask here if it was possible or not.
So as you said I will try to create something based on other API commands to build it.
Thank you both for your time and answers.

Have a good day.