check if QMessageBox::showEvent() may block the resize event ... qt version ..
check if QMessageBox::showEvent() may block the resize event ... qt version ..
Last edited by wagmare; 20th October 2009 at 08:11.
"Behind every great fortune lies a crime" - Balzac
The resize() does not work, I checked QMessageBox::showEvent() but nothing special, and QMessageBox::resizeEvent() just calls QDialog::resizeEvent(). So except if dialogs does not allow resize events, I do not understand why I can't resize my QMessageBox.
I use Qt-4.5 on Max OS X Leopard.
It probably has a constraint set on its layout. One way or another - what is the reason for wanting to resize the dialog? Also maybe it's easier to create your own one from scratch?
Just because my text is too long and QMessageBox resizes its height accordingly and I simply cannot read the end of my text.
Ok I can rewrite anything from scratch but I expect from Qt some easier way to achieve things and being able to resize a window did not appear as a so difficult task lol
Have you tried simply wrapping your text into a paragraph tag?
Qt Code:
#include <QMessageBox> #include <QApplication> int main(int argc, char **argv){ }To copy to clipboard, switch view to plain text mode
This is exactly what I did first. But since the window was too long, I tried to instanciate a new QMessageBox so as to be able to enlarge it.
Did it come to your mind that you may simply be trying to fit too much text into the message box? It is meant for short messages, not esseys. Maybe a custom dialog with QPlainTextEdit or QTextBrowser would be better in your case?
A really nasty hack to make QMessageBox resizable by overriding QMessageBox::event().
The following code resets min/max heights and size policys of the derived QMessageBox on EVERY event calls.
It is slow, but it does work...
Qt Code:
{ setSizeGripEnabled(true); } { setMinimumHeight(0); setMaximumHeight(QWIDGETSIZE_MAX); // make the detailed text expanding if(textEdit) { textEdit->setMinimumHeight(0); textEdit->setMaximumHeight(QWIDGETSIZE_MAX); } return result; }To copy to clipboard, switch view to plain text mode
Last edited by ptorrance; 10th March 2010 at 15:52.
I was searching for something like that. How should *.h file look?
thanks in advance
best regards
Tomasz
I really would avoid using this code. Is seems awfully incorrect to me to force resize of the message box upon any possible event received. To be honest I don't have any problem in fitting large amount of text into a message box without any code manipulations to QMessageBox. Especially that there is QMessageBox::setDetailedText()
Bookmarks