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 could I hide the main window's standard buttons...?
Qt 6.11 is out! See what's new in the release blog

How could I hide the main window's standard buttons...?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 3 Posters 2.8k 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.
  • M Offline
    M Offline
    MSDQuick
    wrote on last edited by MSDQuick
    #1

    Hi:
    I'm new to Qt Quick .
    To begin my first app, I would like to hide the main toolbox of main-window. I mean the "Minimize - Maximize and Close " buttons. I wonder if there is a tutorial for it ...?!

    Thanks for helping...
    MSD.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can take a look at the Window flags example. It shows how you can modify various aspects of your widgets including these buttons.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MSDQuick
        wrote on last edited by MSDQuick
        #3

        Hi "SGaist" ;
        Thanks you for reply and the link ... Actually , I'm new in C++ , so to me the "Window flags example " is somehow complicated. Is there any optimized codes, or can you send me a simple code to remove that buttons...?

        Thanks.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Call:

          setWindowFlags(Qt::WindowTitleHint);
          

          in your main window.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MSDQuick
            wrote on last edited by
            #5

            Hi SGaist :
            I changed my main.cpp to this:

            #include <QApplication>
            #include <QQmlApplicationEngine>
            #include <QMainWindow>
            
            int main(int argc, char *argv[])
            {
                QApplication app(argc, argv);
            
                QQmlApplicationEngine engine;
                QMainWindow qm;
                qm.setWindowFlags(Qt::WindowTitleHint);
                qm.resize(250, 220);
                qm.show();
                //engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
            
                return app.exec();
            }
            
            

            This is works fine, but now , how could I open my "main.qml" file as main window ...?

            (engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); opens the file in another window )

            Thanks.

            D 1 Reply Last reply
            0
            • M MSDQuick

              Hi SGaist :
              I changed my main.cpp to this:

              #include <QApplication>
              #include <QQmlApplicationEngine>
              #include <QMainWindow>
              
              int main(int argc, char *argv[])
              {
                  QApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
                  QMainWindow qm;
                  qm.setWindowFlags(Qt::WindowTitleHint);
                  qm.resize(250, 220);
                  qm.show();
                  //engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
              
                  return app.exec();
              }
              
              

              This is works fine, but now , how could I open my "main.qml" file as main window ...?

              (engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); opens the file in another window )

              Thanks.

              D Offline
              D Offline
              Devopia53
              wrote on last edited by
              #6

              @MSDQuick

              Hi, use the following:

              // in main
              int main(int argc, char *argv[])
              {
                  QGuiApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
                  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
              
                  return app.exec();
              }
              
              // in main.qml
              [...]
              Window {
                  visible: true
                  flags: Qt.WindowTitleHint
              [...]
              
              
              1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Sorry, my bad, I've managed to miss it was for QtQuick. @Devopia53's solution is what you are looking for.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MSDQuick
                  wrote on last edited by
                  #8

                  Thank you Devopia53 (and SGaist):

                  flags: Qt.WindowTitleHint

                  works fine...

                  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