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. Qt QInputDialog, setGeometry: Unable to set geometry
Forum Updated to NodeBB v4.3 + New Features

Qt QInputDialog, setGeometry: Unable to set geometry

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 6.0k 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.
  • S Offline
    S Offline
    Slawomir_Piernikowski
    wrote on last edited by
    #1

    Hi
    My application is composed of widgets which are located in QStackedWidget(one at a time). QStackedWidget is set as the centralWidget of the QMainWindow;
    In One of the Widget :MagazynGui I created QInputDialog as follows:

    bool ok;
        QString nazwaMagazynu =  QInputDialog::getText(this, tr("Utwórz nowy magazyn"), tr("Wprowadź nazwę"), QLineEdit::Normal, tr("Nowy Magazyn"), &ok);
    
        if(ok && !nazwaMagazynu.isEmpty())
        {
            cMagazynModel->SetModelName(nazwaMagazynu);
    
            ui->LviewMagazyny->setModel(&cMagazynModel->CreateMagazyn());
        }
    

    MagazynGui widget and QStackedWidget is created afterwards in QMainWindow(named DomGui).

        widget = new QStackedWidget(this);
        magazynGui =  new MagazynGui(this);
        widget->addWidget(magazynGui);
        setCentralWidget(widget);
    

    So as we launch the program we see DomGui(QMainWindow) in which we have widget(QStackedWidget) and further we have MagazynGui(QWidget) in braces are Qt class names.
    In MagazynGui form I have a push button and when I click on it I execute hereunder code...

    void MagazynGui::on_PbutCreateMagazyn_clicked()
    {
        bool ok;
        QString nazwaMagazynu =  QInputDialog::getText(this, tr("Utwórz nowy magazyn"), tr("Wprowadź nazwę"), QLineEdit::Normal, tr("Nowy Magazyn"), &ok);
    
        if(ok && !nazwaMagazynu.isEmpty())
        {
            cMagazynModel->SetModelName(nazwaMagazynu);
    
            ui->LviewMagazyny->setModel(&cMagazynModel->CreateMagazyn());
         }
    }
    

    ... and unfortunetly I get this statement:

    setGeometry: Unable to set geometry 120x30+1179+658 on QWidgetWindow/'QInputDialogClassWindow'. Resulting geometry: 178x90+1179+658 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x90, maximum size: 524287x90).
    I have been trying to fix it but I can not to find any soluion. Maybe one of you has some idea how to solve the issue.

    I can add that when I created a messagebox instead the inputDialog there was not any statement the like above mentioned.

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

      Hi and welcome to devnet,

      Can you share a minimal compilable sample application that chooses this behaviour ?

      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
      • S Offline
        S Offline
        Slawomir_Piernikowski
        wrote on last edited by
        #3

        Hi
        Thanks for welcome.
        Hereunder there is a minimal compilable sample which creates the same statement:
        setGeometry: Unable to set geometry 120x30+1180+655 on QWidgetWindow/'QInputDialogClassWindow'. Resulting geometry: 178x90+1180+655 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x90, maximum size: 524287x90).
        //MainWindow.h

        #ifndef MAINWINDOW_H
        #define MAINWINDOW_H
        
        #include <QMainWindow>
        #include <QStackedWidget>
        
        class MagazynGui;
        namespace Ui {
        class MainWindow;
        }
        
        class MainWindow : public QMainWindow
        {
            Q_OBJECT
        
        public:
            explicit MainWindow(QWidget *parent = 0);
            ~MainWindow();
        
        private:
            Ui::MainWindow *ui;
            QStackedWidget *widget;
            MagazynGui *magazynGui;
        };
        
        #endif // MAINWINDOW_H
        
        

        //MainWindow.cpp:

        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        #include "magazyngui.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow), widget(new QStackedWidget()), magazynGui(new MagazynGui())
        {
            ui->setupUi(this);
            widget->addWidget(magazynGui);
            setCentralWidget(widget);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
        
        

        MagazynGui.h:

        #ifndef MAGAZYNGUI_H
        #define MAGAZYNGUI_H
        
        #include <QWidget>
        
        namespace Ui {
        class MagazynGui;
        }
        
        class MagazynGui : public QWidget
        {
            Q_OBJECT
        
        public:
            explicit MagazynGui(QWidget *parent = 0);
            ~MagazynGui();
        
        private slots:
            void on_pushButton_clicked();
        
        private:
            Ui::MagazynGui *ui;
        };
        
        #endif // MAGAZYNGUI_H
        
        

        //MagazynGui.cpp

        #include "magazyngui.h"
        #include "ui_magazyngui.h"
        #include <QDebug>
        #include <QInputDialog>
        
        MagazynGui::MagazynGui(QWidget *parent) :
            QWidget(parent),
            ui(new Ui::MagazynGui)
        {
            ui->setupUi(this);
        }
        
        MagazynGui::~MagazynGui()
        {
            delete ui;
        }
        
        void MagazynGui::on_pushButton_clicked()
        {
            bool ok;
            QString nazwaMagazynu =  QInputDialog::getText(this, tr("Create new warehus"), tr("Enter name"), QLineEdit::Normal, tr("New warehus"), &ok);
        
            if(ok && !nazwaMagazynu.isEmpty())
            {
               qDebug() << "I have been just clicked!";
            }
        }
        

        //Test.pro

        #-------------------------------------------------
        #
        # Project created by QtCreator 2018-02-13T22:11:42
        #
        #-------------------------------------------------
        
        QT       += core gui
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = Test
        TEMPLATE = app
        
        # The following define makes your compiler emit warnings if you use
        # any feature of Qt which has been marked as deprecated (the exact warnings
        # depend on your compiler). Please consult the documentation of the
        # deprecated API in order to know how to port your code away from it.
        DEFINES += QT_DEPRECATED_WARNINGS
        
        # You can also make your code fail to compile if you use deprecated APIs.
        # In order to do so, uncomment the following line.
        # You can also select to disable deprecated APIs only up to a certain version of Qt.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        
        SOURCES += \
                main.cpp \
                mainwindow.cpp \
            magazyngui.cpp
        
        HEADERS += \
                mainwindow.h \
            magazyngui.h
        
        FORMS += \
                mainwindow.ui \
            magazyngui.ui
        1 Reply Last reply
        0
        • S Offline
          S Offline
          Slawomir_Piernikowski
          wrote on last edited by
          #4

          I see that it is not so easy.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Maybe "minimum size: 178x90, maximum size: 524287x90" got something to do with (both Y min and Y max are 90).

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Slawomir_Piernikowski
              wrote on last edited by Slawomir_Piernikowski
              #6

              I have allready tried to change minimumSize() and maximumSize() as well. But it does not help.
              What is weird here is that in my first soft(more complex) and in the second one (minimal compilable sample ) the two statements are the same in some of their parts, see:
              The first one:
              setGeometry: Unable to set geometry 120x30+1179+658 on QWidgetWindow/'QInputDialogClassWindow'. Resulting geometry: 178x90+1179+658 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x90, maximum size: 524287x90).
              The second one:
              setGeometry: Unable to set geometry 120x30+1179+658 on QWidgetWindow/'QInputDialogClassWindow'. Resulting geometry: 178x90+1179+658 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x90, maximum size: 524287x90).
              The common parts are:
              Resulting geometry: 178x90+1179+658 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 178x90, maximum size: 524287x90).
              I was googling and found out that the problem could be caused by Windows but I am not sure?????
              My soft working properly but I try to get rid of the statement because it is annoying. You know a lot of red color is alarming
              :-).

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                I can confirm that this warning don't appear on Linux, with exactly the same code and with same Qt versions.

                @Slawomir_Piernikowski try to pass 'Qt::MSWindowsFixedSizeDialogHint' window flag to 'QInputDialog::getText' method, it should remove the warning.

                1 Reply Last reply
                7
                • S Offline
                  S Offline
                  Slawomir_Piernikowski
                  wrote on last edited by Slawomir_Piernikowski
                  #8

                  You have done it!. Great job.
                  Thanks.

                  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