Way to do radio buttons in Qt 4.4.3 menus - qt

On Linux would like to have a set of menu items which are mutually exclusive and have the currently selected one be designated by a radio button instead of a checkbox.
Is there a way to do this in Qt v4.4.3 easily?

I believe you would want to use QtActionGroup to group those menu items which should be mutually exclusive. It also makes them look like a radio button when rendered. Smth like this:
QActionGroup* group = new QActionGroup( this );
ui->actionTest1->setCheckable(true);
ui->actionTest2->setCheckable(true);
ui->actionTest3->setCheckable(true);
ui->actionTest1->setActionGroup(group);
ui->actionTest2->setActionGroup(group);
ui->actionTest3->setActionGroup(group);
3 menu items above should be groped together; more details here : QActionGroup Class Reference

Related

Different options depending on QRadioButton

I have a Qt Designer form (widget), that includes N radio buttons. And i want to see different options (QGroupBox, etc) depending on selected button in the same widget. What is the right way to solve this problem?
Of course, i can place all boxes in widget and change their visibility depending on selected radio button, but that is not perfect i'm sure.
It seems like QStackedWidget is what you're looking for.
Put your radio buttons into a QButtonGroup, then connect QButtonGroup::buttonClicked(int) to QStackedWidget::setCurrentIndex(int).

Toogle single radiobutton (on and off) in bokeh radiobutton group

I am using bokeh single radio button with single title . Initially it is inactive and when i click on radio button it changed to active but if I click again in active it is not changing to inactive state.
How i need to acheive this functionality??
Whether it's RadioGroup or RadioButtonGroup, neither of those two widgets is meant for a single element usage. Per design they are meant to be used as a group of elements. I advice you to use Toggle for your application. Other alternatives are CheckboxButtonGroup and CheckboxGroup. See Bokeh documentation for specific examples.

Is it possible to set a drop down widget to be required?

Was wondering if it was possible to have a drop down widget in app maker be required. In other words, users could not click submit unless they had selected a value from a down down menu. Kind of like how validation on text boxes.
When looking at the property editor for a drop down widget I don't see anything that will allow me to set the above requirement out of the box.
Below is the property editor for a drop down, you will notice there is no validation options.
Below that is the text box property editor with the validation option expanded. I basically need the same functionality for my drop down menu.
If anyone dealt with a similar issue I would appreciate any input.
Of course you have that option.
Look under DropDown menu you will find option called allowNull, deselect that option. Also select validationDisplay check box from 'Other' menu and users will have to choose from a drop down menu always.
Below are the screen for your reference,
Dropdown menu allowNull option,
Other menu validationDisplay option,

Group GUI checkboxes (AbstrackButtons) together and set properties for all of them

I have several radio buttons and checkboxes that all have to be grayed out.
Is their a way to group them and then set the attributes for all of them on the same place?
Example
The QRadioButton and QCheckBox are added to the groupBox (QGroupBox) through the gui designer.
Then do something like this to set all the attributes:
ui->groupBox->setChilrenCheckable()
You can disable the groupbox:
ui->groupBox->setEnabled(false);

Does Qt have combo boxes like Word?

In Microsoft Word, if you want to use Bullets you have a combo box (If we can call it a combo box) to select the shape of the bullet (by clicking the little triangle) or you can just apply the default one by clicking the combo box's button.
Actually the combo box in Word has two parts. For an example let's consider a situation where I want to have a combo box in Qt that has these items as menu items:
"Restart", "Shutdown" and "Log off". User needs to choose one of them but he also can apply previously selected item by clicking its button exactly like Windows shutdown menu in start. You can click Shut down or select another option.
How can we achieve this in Qt?
If you are pursuing after a menu that looks like in the second picture, you can use QToolButton to achieve your goal. Use a QToolButton with popupMode set to MenuButtonPopup. It will render a control something similar to following.
Then you can style the look & feel further more using Qt Style Sheets. Read this example on how to style a QToolButton.
Create a QMenu dynamically, so you can attach it to the QToolButton at run-time in such a way that all items will be included in the menu except for the default item. Default action has to be assigned to the QToolButton itself.
You can use void QToolButton::setMenu (QMenu * menu) to assign a QMenu to your QToolButton at run-time.
If you are trying to design a control that is in your 1st screenshot, you will have to create a custom Qt control I guess. There is no default control available, which can yield that look & feel out of the box.

Resources