Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDialog Showmaximized not working
Forum Updated to NodeBB v4.3 + New Features

QDialog Showmaximized not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.7k Views 2 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.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by
    #1

    After days of research I found that the bug is still there almost 10 years after report.
    This is important for anybody using QinputDialog Ubuntu (I tested on Ubuntu 22.04) : showMaximized() and showNormal() have issues changing the state. This makes setGeometry troublesome as well.

    https://bugreports.qt.io/browse/QTBUG-16034

    I spend hours searching this forum and others finally finding the bug report.

    So if moderators allow let's have it here for record of others searching for the cause.

    JonBJ 1 Reply Last reply
    0
    • Seb TurS Seb Tur has marked this topic as solved on
    • Seb TurS Seb Tur

      After days of research I found that the bug is still there almost 10 years after report.
      This is important for anybody using QinputDialog Ubuntu (I tested on Ubuntu 22.04) : showMaximized() and showNormal() have issues changing the state. This makes setGeometry troublesome as well.

      https://bugreports.qt.io/browse/QTBUG-16034

      I spend hours searching this forum and others finally finding the bug report.

      So if moderators allow let's have it here for record of others searching for the cause.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Seb-Tur
      That issue refers to "metacity" under GNOME. I don't know that it has general/any applicability nowadays. It also is about whether min/max buttons can be shown on a dialog, whereas you seem to be asking about code.

      FWIW I tried under 22.04 and it seemed to work OK. Default GNOME/Mutter. showMaximized() seem to work from code. I cannot be sure what else you saw for "troublesome".

      Seb TurS 1 Reply Last reply
      0
      • JonBJ JonB

        @Seb-Tur
        That issue refers to "metacity" under GNOME. I don't know that it has general/any applicability nowadays. It also is about whether min/max buttons can be shown on a dialog, whereas you seem to be asking about code.

        FWIW I tried under 22.04 and it seemed to work OK. Default GNOME/Mutter. showMaximized() seem to work from code. I cannot be sure what else you saw for "troublesome".

        Seb TurS Offline
        Seb TurS Offline
        Seb Tur
        wrote on last edited by Seb Tur
        #3

        @JonB

        tested again on mine,

           QDialog dialog(parent_widget);
           dialog.setObjectName("messageDialog");
           dialog.setWindowIcon(icon);
           dialog.setWindowTitle(title);
           dialog.setWindowFlags(Qt::Window);
           dialog.showMaximized();
           bool res = dialog.exec()
        

        if I skip setWindowFlags(Qt::Window) then dialog is not maximized at all

        JonBJ 1 Reply Last reply
        1
        • Seb TurS Seb Tur

          @JonB

          tested again on mine,

             QDialog dialog(parent_widget);
             dialog.setObjectName("messageDialog");
             dialog.setWindowIcon(icon);
             dialog.setWindowTitle(title);
             dialog.setWindowFlags(Qt::Window);
             dialog.showMaximized();
             bool res = dialog.exec()
          

          if I skip setWindowFlags(Qt::Window) then dialog is not maximized at all

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Seb-Tur
          Tested on mine: Ubuntu 22.04, Qt 5.15.3, GNOME. Works fine (maximizes) with or without setWindowFlags(Qt::Window).

          Check you are running under Xorg, not Wayland? Wayland may not allow such stuff?

          1 Reply Last reply
          0
          • Seb TurS Seb Tur has marked this topic as unsolved on
          • Seb TurS Offline
            Seb TurS Offline
            Seb Tur
            wrote on last edited by
            #5

            Reopening,
            now I tried to make a windows10 build for my app and show dialog.showMaxmized() does not work, the window is just a fraction of the screen.

            this is how i do it:

                if (touchscreen) {
                    qDebug()<<"Showing maximized, it is touchscreen";
                    setWindowFlags(windowFlags() | Qt::Window);
                    setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
                    showMaximized();
                } else {
                    qDebug()<<"no touchscreen, getting screen geometry and calculate the size to occupy half of the screen";;
                    QRect screenGeometry = QApplication::primaryScreen()->geometry();
                    int width = screenGeometry.width() / 2;
                    int height = screenGeometry.height() / 2;
                    int x = (screenGeometry.width() - width) / 2;
                    int y = (screenGeometry.height() - height) / 2;
            
                    // Set the geometry of the dialog to be centered and occupy half the screen
                    setGeometry(x, y, width, height);
                    show();
                }
            
                exec();
            
            jsulmJ 1 Reply Last reply
            0
            • Seb TurS Seb Tur

              Reopening,
              now I tried to make a windows10 build for my app and show dialog.showMaxmized() does not work, the window is just a fraction of the screen.

              this is how i do it:

                  if (touchscreen) {
                      qDebug()<<"Showing maximized, it is touchscreen";
                      setWindowFlags(windowFlags() | Qt::Window);
                      setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
                      showMaximized();
                  } else {
                      qDebug()<<"no touchscreen, getting screen geometry and calculate the size to occupy half of the screen";;
                      QRect screenGeometry = QApplication::primaryScreen()->geometry();
                      int width = screenGeometry.width() / 2;
                      int height = screenGeometry.height() / 2;
                      int x = (screenGeometry.width() - width) / 2;
                      int y = (screenGeometry.height() - height) / 2;
              
                      // Set the geometry of the dialog to be centered and occupy half the screen
                      setGeometry(x, y, width, height);
                      show();
                  }
              
                  exec();
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Seb-Tur said in QDialog Showmaximized not working:

              Showing maximized, it is touchscreen

              Is this printed if you run your app?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Seb TurS Offline
                Seb TurS Offline
                Seb Tur
                wrote on last edited by Seb Tur
                #7

                yes it is printed
                I also do check
                qDebug()<<"isMaximized: "<<isMaximized();
                which returns 1 after showMaximized() even if the window does not get maximized.

                my dirty trick right now is to add

                #ifdef Q_OS_WIN
                        QWidget *parentWidget = static_cast<QWidget *>(parent());
                        if (parentWidget)
                            setGeometry(parentWidget->geometry());
                #endif
                

                just after showMaximized()

                1 Reply Last reply
                0
                • Seb TurS Offline
                  Seb TurS Offline
                  Seb Tur
                  wrote on last edited by
                  #8

                  what is strange that showFullScreen() works ok

                  Pl45m4P 1 Reply Last reply
                  0
                  • Seb TurS Seb Tur

                    what is strange that showFullScreen() works ok

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by
                    #9

                    @Seb-Tur said in QDialog Showmaximized not working:

                    what is strange that showFullScreen() works ok

                    Therefore check this topic.


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    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