I want when pushing the clear all choices button, all checkboxes and radio buttons are be unchecked.
void MainWindow::on_pushButton_clicked()
{
ui->checkBox->setChecked(false);
ui->radioButton->setChecked(false);
// Add all other check boxes and radio buttons you have...
}
Related
I have two buttons YES and NO.
If user click on the yes Button the Dropdown menu like Spinner should appear
which contains other parameters related to Yes.
user will select one Parameter from that menu(dropdown menu)
I used this line for spinner button
android:background="#android:drawable/btn_dropdown"
OnClick method for Button:
ArrayList<String> spinnerArray = new ArrayList<String>();
spinnerArray.add("one");
spinnerArray.add("two");
spinnerArray.add("three");
spinnerArray.add("four");
spinnerArray.add("five");
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setOnItemSelectedListener(this);
with this code my button is look like spinner but on Click dropdown menu not appearing.
How to do this.?????
set your spinner launch mode to dialog android:spinnerMode=dialog this will display a dialog on click and let the user choose a option.
I need to use QTableWidget with checkboxes instead of text in items. Checkbox must be in the center of item.
Examples which I tried work while checkbox is checked. If I uncheck checkbox it disapeares.
You can set the checkbox to be centered with this code:
QWidget *pWidget = new QWidget();
QCheckBox *pCheckBox = new QCheckBox();
QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
pLayout->addWidget(pCheckBox);
pLayout->setAlignment(Qt::AlignCenter);
pLayout->setContentsMargins(0,0,0,0);
pWidget->setLayout(pLayout);
pMyTableWidget->setCellWidget(0,0,pWidget);
(I don't know if I understood you well here) And if you want to make your checkbox disappear when you uncheck it, you need to connect clicked signal of checkbox to a slot, that will make your checkbox invisible. Use connect method like this:
connect(checkbox,SIGNAL(clicked()),this,SLOT(checkboxClicked()));
You need to create slot checkboxClicked where you will be checking if the checkbox is checked or not. If not then you have to set it invisible. Example:
QCheckBox* Chb = qobject_cast<QCheckBox *>(QObject::sender());
if(!Chb->checked())
Chb->setVisible(false);
I am using scenebuilder to make the UI. I want to make the color of the buttons change when mouse is pressed or when the button is touched. Can I set the same method for both mouse pressed and screen touched events and also set the same events for multiple buttons? Like there are 3 buttons and I want to change their color in mouse pressed and screen touched events and use only one method for all.
Thank you
Lets say, you have three buttons
Button button1 = new Button();
Button button2 = new Button();
Button button3 = new Button();
Create a method saying
private void handleButtonAction(ActionEvent event) {
// Button was clicked, change color
((Button)event.getTarget).setStyle("-fx-background-color:PINK");
}
All buttons have a setOnAction() which is fired on both mouse pressed and screen touched events.
JavaDoc says
The button's action, which is invoked whenever the button is fired.
This may be due to the user clicking on the button with the mouse, or
by a touch event, or by a key press, or if the developer
programmatically invokes the fire() method.
Use it :
button1.setOnAction(this::handleButtonAction);
button2.setOnAction(this::handleButtonAction);
button3.setOnAction(this::handleButtonAction);
If you are using FXML
You can define one action for all buttons :
<Button id="button1" onAction="#handleButtonAction"/>
<Button id="button2" onAction="#handleButtonAction"/>
<Button id="button3" onAction="#handleButtonAction"/>
Inside the controller :
#FXML
private void handleButtonAction(ActionEvent event) {
// Button was clicked, change color
((Button)event.getTarget).setStyle("-fx-background-color:PINK");
}
I have a child class of QGraphicsItem with Selectable and Movable flags. When I select many items and moving them, all recieves itemChange event. Is there any way to detect in itemChanged that mouse's button is still pressed?
Please refer to the QApplication::mouseButtons() function that will return the current state of the mouse buttons Qt::MouseButtons.
Qt::MouseButtons btns = QApplication::mouseButtons();
if (btns & Qt::LeftButton) {
// The left button is pressed.
[..]
}
I have a TextArea and a Checkbox. I want to disable the SoftKeyboard when the checkbox is checcked, so the TextArea can be scrolled without it popping up. I can get the keyboard to disable when the Checkbox is clicked, but as soon as I click on the TextArea to scroll it pops back up. How do I enable/disable the keyboard with a checkbox? Below is my code:
protected function toggle_keyboard_clickHandler(event:MouseEvent):void
{
checkboxStatus = event.target.selected;
if(checkboxStatus == true){
SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE;
}else{}
}
A SoftKeyboardEvent object is dispatched when a software-driven keyboard is activated or de-activated on a device or operating system. A SoftKeyboardEvent object is dispatched by a TextField or InteractiveObject that has the needsSoftKeyboardproperty set to true.