On 2 Apr 2014, at 11:53 AM, Sensei wrote:

> Dear all,
> 
> How can I reproduce the aesthetics of a QMessageBox::warning and similar 
> static functions?
> 
> I am trying to make a platform-specific dialog box that handles 
> informativeText (yes, just that! at least for now).
> 
> However, I don't know how to retrieve the default sizes, and printing 
> them isn't really working:
> 
> 
>     QMessageBox m(QMessageBox::Warning, "Error", "An error occurred. 
> Please make sure to tirelessly debug errors, and correct them before 
> it's too late.");
>     qWarning("geometry %d %d max %d %d", m.geometry().width(), 
> m.geometry().height(), m.maximumWidth(), m.maximumHeight());
> 
> 
> The output isn't what I expected:
> 
>     geometry 640 480 max 16777215 16777215

This is a minimalist dialog which doesn't take up any more space than 
necessary, so the default size will depend on what is being displayed, and is 
determined by the layout (see e.g. QMessageBoxPrivate::layoutMinimumWidth()).  
After you show the dialog it should have different geometry, because the layout 
will have done its computations before the window was shown.

There is a QPA interface for native message dialogs now, so you could implement 
that on your platform (and ideally share it afterwards, if it's a platform 
where we should have it and do not yet).  For example you can look at 
qtbase/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp and 
winrt/qwinrtplatformmessagedialoghelper.cpp This way the same implementation 
will work whether you create a QMessageBox in your C++ application or a 
MessageDialog in Qt Quick.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to