Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to prevent closing the window
Forum Updated to NodeBB v4.3 + New Features

How to prevent closing the window

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trikrista
    wrote on last edited by
    #1

    The window is created using the QQuickView,
    How to prevent closing the window?

    I'm sorry for my bad English

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      How did you create the window ? Did you use Item as root component ?

      157

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trikrista
        wrote on last edited by
        #3

        I create the window like this:

        @
        class MyWindow : public QQuickView {
        public:
        MyWindow() {
        setSource(QUrl("main.qml"));
        pView->show();
        }
        }
        @

        I'm sorry for my bad English

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          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.

          157

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Trikrista
            wrote on last edited by
            #5

            I tried closing(QQuickCloseEvent*) and eventFilter(QObject *, QEvent *) .

            closing(QQuickCloseEvent*) not fit
            eventFilter(QObject *, QEvent *) not work when closing window

            I'm sorry for my bad English

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              Did you "installEventFilter":http://doc.qt.io/qt-5/qobject.html#installEventFilter ? You can do it in constructor
              @
              installEventFilter(this);
              @

              157

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved