QMessageBox too small
-
[quote author="Serenity" date="1360759711"]Thank you, it seems to work with your work around.
But I am still wondering, why it doesn't resize by itself.
[/quote]I have no idea with setFixedWidth didn't work as expected too. In fact the work around is not mine. As I said I found it at "an old thread at Qt Centre":http://www.qtcentre.org/threads/22298-QMessageBox-Controlling-the-width?p=113348#post113348
-
Has anybody found a solutions to this? I tried http://www.qtcentre.org/threads/22298-QMessageBox-Controlling-the-width?p=113348#post113348 to no avail. Is seems my QMessageBox won't expand beyond it's internal maximum width.
-
@DougyDrumz
hi this does work for me#include <QMessageBox> #include <QGridLayout> #include <QSpacerItem> void MainWindow::on_pushButton_released() { QMessageBox msg; msg.setIconPixmap(QPixmap(":/error.svg")); msg.setText("No images loaded"); msg.setInformativeText("There are no images in the list. Please create or load a project"); msg.setStandardButtons(QMessageBox::Ok); msg.setDefaultButton(QMessageBox::Ok); QSpacerItem* horizontalSpacer = new QSpacerItem(800, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QGridLayout* layout = (QGridLayout*)msg.layout(); layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); msg.exec(); }
-
This doesn't work for me. One thing I've noticed: You're opening this QMessageBox in a QMainWindow. My QMessageBox is opened in main. This is because I open the QMessageBox using an executable from the command line. It's not tied to any app. Could that be an issue? If it helps, I'm running Qt 4.6.2 on RHEL 6 machine.
-
@DougyDrumz
win 7, qt 5.5
well im not using "this" from mainwindow ,
so should be same as in main.cpp
Let me try.
update:
also works from main.Maybe its diff between win and linux. But looking at code it seems that
its build with qt widgets so should function the same. -
hi
could you try for test to run this#include <QList> void Pop() { QMessageBox msg; msg.setIconPixmap(QPixmap(":/error.svg")); msg.setText("No images loaded"); msg.setInformativeText("There are no images in the list. Please create or load a project"); msg.setStandardButtons(QMessageBox::Ok); msg.setDefaultButton(QMessageBox::Ok); QList<QObject*> widgets = msg.findChildren<QObject*>(); for (int var = 0; var < widgets.size(); ++var) { qDebug() << widgets[var]->objectName() << widgets[var]->metaObject()->className(); } msg.exec(); }
its lists all objects.
my list is
"qt_msgboxex_icon_label" QLabel
"qt_msgbox_label" QLabel
"qt_msgbox_buttonbox" QDialogButtonBox
"" QHBoxLayout
"" QPushButton
"" QGridLayout
"qt_msgbox_informativelabel" QLabel
just too see if inner layout is different for you. -
Same objects, different order:
"" QGridLayout
"qt_msgboxex_icon_label" QLabel
"qt_msgbox_label" QLabel
"qt_msgbox_buttonbox" QDialogButtonBox
"" QHBoxLayout
"" QPushButton
"qt_msgbox_informativelabel" QLabel -
@DougyDrumz
Ok, nothing exciting there.
looking at the code in qmessagebox.cpp i see nothing that should it do different
on linux.
Have you looked in your version ?
seems like it's a lost cause as most of the stuff is in private.