- 1 year ago
qt Window make no modal (Windows)
Comment
1 / 1
To create a Qt window that is non-modal on Windows, you can set the window's modality to Qt::NonModal
. Here's an example:
cpp#include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow mainWindow;
// Set the window's modality to non-modal
mainWindow.setWindowModality(Qt::NonModal);
mainWindow.show();
return app.exec();
}
In this example, a QMainWindow
is created, and its modality is set to Qt::NonModal
using the setWindowModality()
function. This allows the window to be non-modal, meaning it won't block user interaction with other windows in the application.
Make sure you have the necessary includes for QApplication
and QMainWindow
. Also, remember to link against the necessary Qt libraries when compiling your application.
Note that this code snippet assumes you have a Qt development environment properly set up.