Unsolved QButtonGroup for custom buttons
-
Hello all! I faced with the following issue: can not correctly create QButtonGroup for my own buttons derived from QAbstractButton. In widget grouping several radio or pushbuttons is okay, but grouping my custom buttons fails. In this cases QButtonGroup is created (in QtCreator object window), but, as I could see in ui_xxx.h file, there is no creating of the object QPushButton: just declaring it. Looks like there is something that I have missed when was creating my buttons. Where could I find the root of my issue?
Thank in advance!
<Qt version 5.13, Linux x64>
-
Hi
What you mean excactly?
Do you promote QPushbuttons to your custom pushbuttons and then try to make a group or
how do you do it ? -
@mrjj not promote, but previously I have created a widget and plugin's library to use it with QtDesigner. Then I added my custom button from widget library (left window in QtCreator) and tried to assign to button group.
-
Hi
Ok so its a true custom button from a Designer plugin.
Does the button work in all other regards ?Im have not tried withb a true custom button. There could be some issue even
i dont see why.So the code generated in the UI_ file is not correct or what happens ?
-
@mrjj Yes, I can see it in QtDesigner, paintEvent works well, this button is working (being placed in different widgets) well too.
If I place 2 QPushButtons and create QButtonGroup of them, QtCreator places in the ui_mywidget.h following lines:
class Ui_mywidget { public: <...> QButtonGroup *buttonGroup; void setupUi(QWidget *Chamber) { pushButton = new QPushButton(groupBox); buttonGroup = new QButtonGroup(MyWidget); buttonGroup->setObjectName(QStringLiteral("buttonGroup")); buttonGroup->addButton(pushButton); pushButton->setObjectName(QStringLiteral("pushButton")); gridLayout_main->addWidget(pushButton, 6, 0, 1, 1); pushButton_2 = new QPushButton(groupBox); buttonGroup->addButton(pushButton_2); pushButton_2->setObjectName(QStringLiteral("pushButton_2")); gridLayout_main->addWidget(pushButton_2, 6, 1, 1, 1); } }
Assigning my two custom button creates only
class Ui_mywidget { public: <...> QButtonGroup *buttonGroup_2; }
Without any creating (with
new
operator) neither adding my custom buttons.
I hope I've described my issue clearly :) -
Hi
yes its very clear.
Seems like a bug.it seems that Creator allow you to make it visually but then fails to
generate the code.
Just to be 100% sure, you select your custon buttons and do
?
-
@mrjj Yes. Moreover, I have tried two ways: use this context menu from the central window (graphical ui) and from the right window (objects list). just in case :)
I don't know, is it important or not, but this assignment includes QButtonGroup header in ui_chamber.h too:
#include <QtWidgets/QButtonGroup>
-
Hi
Well its a bit odd as normally the options is just not there is not right classes/types so since it allows it, one should think it should work.
Give it some hours and see if someone has an idea.
I know writing a small sample is a bit hard as its a plugin.Im trying to find some other Designer button i could try with and see if it generally do not work
or there could be something in the plugins XML or similar that needs filling out.