How to change size of QDialog??
-
It seams that i'm too stupid to change the size of my QDialog.
Here is the code:QMessageBox* dialog = new QMessageBox(QMessageBox::Information, WINDOW_NAME, QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))), QMessageBox::StandardButton::Close, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8))); dialog->resize(500, 1000); dialog->exec(); delete dialog;
I just want to set a minimum width. But nothing works:
QMessageBox* dialog = new QMessageBox(QMessageBox::Information, WINDOW_NAME, QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))), QMessageBox::StandardButton::Close, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8))); dialog->setMinimumWidth(500); dialog->exec(); delete dialog;
I tried to set the sizepolicy, but i always get error messages, when i try that.
-
Hi
Do you mean QMessageBox ?
It is not really supported but hacks exists.
http://stackoverflow.com/questions/37668820/how-can-i-resize-qmessagebox
Also see this "bug" report.
https://bugreports.qt.io/browse/QTBUG-7851 -
Works fine. Do you know how to remove the "bling" when i use QMessageBox::Information?? I want that i icon, but i don't want it to make sound
-
Works fine. Do you know how to remove the "bling" when i use QMessageBox::Information?? I want that i icon, but i don't want it to make sound
@QT-static-prgm said in How to change size of QDialog??:
but i don't want it to make sound
Hi
Never tried it but
http://stackoverflow.com/questions/16070012/how-can-i-disable-sounds-played-by-qt-qmessagebox -
@QT-static-prgm said in How to change size of QDialog??:
but i don't want it to make sound
Hi
Never tried it but
http://stackoverflow.com/questions/16070012/how-can-i-disable-sounds-played-by-qt-qmessagebox@mrjj Hello
How will you change the size of QDialog not the QMessageBox ?
I am doing like this:
fileDialog->resize(m_measDialogWidth, m_measDialogHeight);Somehow it is not setting the width and height at all.
I am always getting the default width and height.Thanks
-
@mrjj Hello
How will you change the size of QDialog not the QMessageBox ?
I am doing like this:
fileDialog->resize(m_measDialogWidth, m_measDialogHeight);Somehow it is not setting the width and height at all.
I am always getting the default width and height.Thanks
-
@QtVik
Hi
is that a Qt FileDialog or just your own QDialog based dialog ?If you have an UI file with your dialog, you can directly set size there.
-
@QtVik
Hi
is that a Qt FileDialog or just your own QDialog based dialog ?If you have an UI file with your dialog, you can directly set size there.
@mrjj No.. it is Qt FileDialog.
Following is the code:
QFileDialog* fileDialog = new QFileDialog(this);
fileDialog->setWindowTitle("Open Meas File");
fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
fileDialog->setNameFilter(tr("DAT (*.dat)"));
fileDialog->setGeometry(this->x(), this->y(),this->m_measDialogWidth, this->m_measDialogHeight);
.....
if(fileDialog->exec())
{
.....
}Note: m_measDialogWidth and m_measDialogHeight always has the previously set width/height
using setGeometry i am able to set the position but not the width and height.
why is that ?Thanks
-
@mrjj No.. it is Qt FileDialog.
Following is the code:
QFileDialog* fileDialog = new QFileDialog(this);
fileDialog->setWindowTitle("Open Meas File");
fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
fileDialog->setNameFilter(tr("DAT (*.dat)"));
fileDialog->setGeometry(this->x(), this->y(),this->m_measDialogWidth, this->m_measDialogHeight);
.....
if(fileDialog->exec())
{
.....
}Note: m_measDialogWidth and m_measDialogHeight always has the previously set width/height
using setGeometry i am able to set the position but not the width and height.
why is that ?Thanks
Ok. When a platform (OS) has a FileDialog, Qt uses that one.
Called the native Dialog and that is why the setGeometry is ignored.
(on linux for instance it can remember the size so it will load some size when shown)You can use
fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);and you can then resize it. but it uses Qt version of FileDialog.
Not the one from the OS. -
Ok. When a platform (OS) has a FileDialog, Qt uses that one.
Called the native Dialog and that is why the setGeometry is ignored.
(on linux for instance it can remember the size so it will load some size when shown)You can use
fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);and you can then resize it. but it uses Qt version of FileDialog.
Not the one from the OS.