Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › window maximize button disable

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #18640

    Bas

    hi,

    I need to disable the maximize button in a windows application.

    is this possible with some easy property setting?

    or do i need to traverse active window and try to disable it myself?

    thanx Bas

     

    #18641

    Bas

    ok i found a solution,

    i created a class in c++ with a single function to correct the main window by getting the main window and correct the window and restrict resize.

    the function is called from qml, because i do not know when the window is active.

    in main.qml it is active.

        void correctWindowSize() {
    
            QWindow *mw = getMainWindow();
            if( mw == nullptr ) {
                qDebug() << "WINDOW NOT FOUND";
            }
            else {
                Qt::WindowFlags flags = 0;
                flags |= Qt::Dialog;
    //            flags |= Qt::Tool;
    //            flags |= Qt::WindowTitleHint;
    
                mw->setFlags(flags);
                mw->setMinimumWidth(mw->width());
                mw->setMinimumHeight(mw->height());
                mw->setMaximumWidth(mw->width());
                mw->setMaximumHeight(mw->height());
            }
        }
    
        QWindow* getMainWindow()
        {
            foreach (QWindow *w, qApp->allWindows()) {
                if(w->inherits("QWindow")) {
                    qDebug() << "window found";
                    return w;
                }
            }
            return nullptr;
        }
    
    

     

    #18642

    Günther
    Felgo Team

    Hi Bas,

    as the QML App and GameWindow types are based on ApplicationWindow, you can set flags or minimum sizes also from QML:

     

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
    
      flags: Qt.Dialog
    
      // ...
    }
    

    Best,
    Günther

    #18643

    Bas

    ok thanx, but how do i restrict the resizing?

    #18644

    Bas

    sorry i need to read the docs 🙂

    #18645

    Bas

    ah yes, i saw that the editor was saying invalid property name… that is how i ended up with a weird workaround

    #18647

    Günther
    Felgo Team

    Yes, Qt Creator does not offer properties of the derived type ApplicationWindow in auto-completion at the moment, which is a bit confusing.

    #18648

    Bas

    hmm

    the minimum width/height is not working

     

        contentItem.maximumWidth : 640
        contentItem.maximumHeight : 960
        contentItem.minimumWidth : 640
        contentItem.minimumHeight : 960
    

     

    #18659

    Günther
    Felgo Team

    You can set the properties directly for the window instead of contentItem:

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
    
      flags: Qt.Dialog
    
      maximumWidth : 640
      maximumHeight : 960
      minimumWidth : 640
      minimumHeight : 960
    }
    

     

Viewing 9 posts - 1 through 9 (of 9 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded