Running a new form with the click of a button in a qt gui application?

I am trying to use some simple applications. I would like to know how to launch a new form by clicking a button from the main window. Please explain this to me with a simple example.

+3
source share
1 answer

QT already contains a simple example of how to create and display different types of windows and dialogs. Have a look here: Example of checkboxes with windows

In addition, if you already have a main widow in the application, you can see how it is shown (a mainfunction in your main.cpp) for your project and use the same method:

MainWindowTest *testWindow = new MainWindowTest();
testWindow->show();

If you need to show a modal dialog, use the dialog method exec():

Dialog *dialog = new Dialog();
dialog->exec();

, ,

+3

Source: https://habr.com/ru/post/1793560/


All Articles