Can this be done in Qt?
-
In one of my wxWidgets projects, I use the following code:
void Fishermen::onUpdateAddMCButton( wxUpdateUIEvent &event ) { event.Enable( false); // disables the Ok button if (!TextCtrl_Add_Question->GetValue().empty() ) if (!TextCtrl_Answer1->GetValue().empty() ) if (!TextCtrl_Answer2->GetValue().empty() ) if (!TextCtrl_Answer3->GetValue().empty() ) if (!TextCtrl_Answer4->GetValue().empty() ) { int selection = Choice_The_Answer_MC->GetSelection(); if (selection != wxNOT_FOUND) // equals -1 (no selection) event.Enable( true); } }
It makes sure there's text in the four TextCtrls and that something got selected in the comboBox. Once those conditions are satisfied, the OK button gets enabled.
Does Qt have a similar ability?
-
Hi,
You can do the same kind of validation yes.
-
A slot for what? I'm sure there is, no matter what you are going to answer (the default ones, of course).
Custom behavior must be implemented depending on what you want to do with your text and widgets :)
Like @mchinand said, a slot connected to thetextChanged
signal of every text field could work for you.
You can check the content of textBoxes or comboBoxes and perform the rest of your actions. The syntax might change from wxWidgets to Qt.for example:
if(!(lineEdit->text().isEmpty())){}