How to prevent closing the window
-
The window is created using the QQuickView,
How to prevent closing the window? -
Hi,
How did you create the window ? Did you use Item as root component ?
-
I create the window like this:
@
class MyWindow : public QQuickView {
public:
MyWindow() {
setSource(QUrl("main.qml"));
pView->show();
}
}
@ -
You can use closing(QQuickCloseEvent*) signal and connect to a slot and reject the close event, but the problem here is that QQuickCloseEvent is not public and hence we cannot call its methods.
The only way I think would be to installEventFilter and look out for close event in *eventFilter(QObject *, QEvent ) and when you get it just ignore it.
-
I tried closing(QQuickCloseEvent*) and eventFilter(QObject *, QEvent *) .
closing(QQuickCloseEvent*) not fit
eventFilter(QObject *, QEvent *) not work when closing window -
Did you "installEventFilter":http://doc.qt.io/qt-5/qobject.html#installEventFilter ? You can do it in constructor
@
installEventFilter(this);
@