Disable window maximizing/showing in QML



  • I have an application in the QML/C++ that shouldn't be able to be maximized/showed by user. It should stay minimized in taskbar whole time and when it receives a message from a server then it should maximize itself. Is it possible to do it in the QML? I was looking everywhere and I was not able to find anything similar to my issue.


  • Moderators

    Hi,

    If you are using Window then set Window visibility to Maximized and then call requestActivate() when messaged is received from server.



  • Hey,

    like p3c0 already said; the window visibility should do the trick. Example code with a Window-type Component:
    @import QtQuick 2.2
    import QtQuick.Window 2.1

    Window {
    visible: true
    visibility: "Minimized"
    }@

    For the cpp part where a user shouldn't be able to maximize your application:

    @void MyApplication::changeEvent(QEvent *e)
    {
    if(e->type() == QEvent::WindowStateChange) {
    e->ignore();
    } else {
    e->accept();
    }
    }@

    This should ignore the event by default, i haven't tested it out so you might play around with it a little bit to get it work properly.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.