Solved Qt QInputDialog, setGeometry: Unable to set geometry
-
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.
-
Hi and welcome to devnet,
Can you share a minimal compilable sample application that chooses this behaviour ?
-
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
#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
#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!"; } }
#------------------------------------------------- # # 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
-
I see that it is not so easy.
-
Maybe "minimum size: 178x90, maximum size: 524287x90" got something to do with (both Y min and Y max are 90).
-
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
:-). -
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.
-
You have done it!. Great job.
Thanks.