Create a new file:
Press the key to go to the slot and add the slot function:
void mainwindow::on_pushbutton_clicked ()
{
Com_config * c = new com_config ();
C->show (); c->exec ();
}
Ps:
defined as Com_config c = new Com_config (), the interface will flash back. is defined as a pointer type and does not flash back.
Pop-up interface:
Add "OK" and "Cancel" buttons:
button to go to the slot to add code:
void com_config::on_pushbutton_ok_clicked ()
{
com_config::accept ();
}
void com_config::on_button_reject_clicked ()
{
com_config::reject ();
}
Ps:
1. Close the main window and exit the program is Qapplication::exit ()
2. If it is Qdialog, accept () or reject ()
3. For all Qwidget:close ()
Pps:
Show () differs from EXEC ():
Show ():
Displays a non-modal dialog box. Control is immediately returned to the calling function.
The popup window is a modal dialog box, depending on the value of the modal property.
EXEC ():
Displays a modal dialog box and locks the program until the user closes the dialog box. The function returns a dialogcode result.
During a dialog pop-up, the user cannot switch to another window under the same program until the dialog box is closed.
Let me start with a little bit of understanding of the modal and modeless dialogs:
Modal dialog box, the entire program is locked and waiting until the dialog box is closed when the popup window is displayed. The return value of the dialog box is often required to do the following. Such as: Confirmation window (select Yes or no).
Non-modal dialog box, after calling the pop-up, the call returns immediately, continuing with the following operation. Here is just a call to the command to emit, do not wait nor do any processing. such as: Find box.
If you want to fix the size of the dialog box, you can use two methods:
One way is to set its maximum size and minimum size, and make their values equal, equal to the size of the window you are currently setting.
A simple example:
Setminimumsize (370, 150);
Other such as height and width can generally be ignored.
Another way is to use setfixedsize (), so that a sentence can solve the problem.
A simple example:
A practical example:
As a result of this setting, even the maximum Minimum button of the dialog box is
this->setfixedsize (This->width (), This->height ());