[Qt-interest] any planned improvement to QMessageBox interfaces?
Malyushytsky, Alex
alex at wai.com
Tue Nov 10 01:41:51 CET 2009
Ross,
You should not count on the future not implemented yet.
Make the code work the way you need now.
Implementing it takes less time than discussing and you don't to have to change it in the future,
if ever such functionality is implemented in the future.
>> (although I don't agree with your proposed interface since it makes assumptions about the order of
the text strings).
Use whatever assumptions you prefer.
Replace QStringList with a map, map button id (QMessageBox::Yes) to the string.
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ross Bencina
Sent: Sunday, November 08, 2009 7:44 PM
To: Qt-Interest
Subject: Re: [Qt-interest] any planned improvement to QMessageBox interfaces?
Hello Alex
There is nothing stopping me doing as you describe (although I don't agree
with your proposed interface since it makes assumptions about the order of
the text strings).
But my question remains: is there anything like this planned for Qt4.6 or
later? It's a standard requirement for message boxes these days and I'd
prefer not to invent my own way and then have to re-write (again) to the Qt
way later.
Thanks!
Ross.
----- Original Message -----
From: "Malyushytsky, Alex" <alex at wai.com>
To: "Qt-Interest" <qt-interest at trolltech.com>
Sent: Friday, November 06, 2009 12:56 PM
Subject: Re: [Qt-interest] any planned improvement to QMessageBox
interfaces?
> First I would like to comment that "Erase the Hard Disk" does not fall in
> "use-verbs-as-labels" concept.
> It is more like "use-sentences-as-labels", in this case I would prefer
> yes/no.
>
> Anyway, if you need to be able to specify the labels, what prevents you
> from writing your static function(s) which do it.
> (It probably not worth to derive your class from QMessageBox just to add
> static functions, so you might keep them global)
>
>
> Assume you had the following code:
> int ret = QMessageBox::critical( parent, title, text ) ;
>
> Create static functions, declared as:
>
> QMessageBox::StandardButton criticalMessageBox ( QWidget * parent, const
> QString & title, const QString & text, QMessageBox::StandardButtons
> buttons = Ok, QMessageBox::StandardButton defaultButton = NoButton,
> QStringList* buttonLabels = NULL )
>
> Or for convenience you can provide2 functions:
>
> QMessageBox::StandardButton criticalMessageBox ( QWidget * parent, const
> QString & title, const QString & text, StandardButtons buttons = Ok,
> QStringList* buttonLabels = NULL );
>
>
>
> Replace the text "QMessageBox::critical" on "criticalMessageBox" in all
> files.
> (Make sure you include header with criticalMessageBox declarations)
>
>
> You should have
> int ret = criticalMessageBox ( parent, title, text ) ;
>
> Now everything should work the same way it was before.
>
> When you ready to replace the text on the buttons, add the code :
> QStringList lst;
> lst << qApp->tr("Erase the Hard Disk")
> << qApp->tr("Don't erase the Hard Disk");
>
> int ret = criticalMessageBox ( parent, title, text, & lst ) ;
>
> Possible implementation of your static function:
>
> QMessageBox::StandardButton criticalMessageBox ( QWidget * parent, const
> QString & title, const QString & text, QMessageBox::StandardButtons
> buttons, QMessageBox::StandardButton defaultButton,
> QStringList* buttonLabels = NULL )
> {
> QMessageBox::StandardButton ret;
> if(buttonLabels)
> {
> ret = QMessageBox::critical( parent, title, text, buttons,
> defaultButton);
> }
> else
> {
>
> QMessageBox messageBox(parent);
> messageBox->button(QMessageBox::Yes)->setText("Erase the Hard Disk");
> messageBox->button(QMessageBox::No)->setText("Don't erase the Hard
> Disk");
> .... // set title, text, buttons
>
> ret = messageBox->exec();
> }
>
> That is it.
>
> Regards,
> Alex
>
>
>
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ross Bencina
> Sent: Wednesday, November 04, 2009 7:24 PM
> To: Qt-Interest
> Subject: [Qt-interest] any planned improvement to QMessageBox interfaces?
>
> Hi
>
> I'm planning to improve my app by replacing the standard Yes/No/Cancel
> buttons in all my QMessageBox calls with context specific verbs as per
> current user interface guidelines. eg
> http://www.usabilitypost.com/2008/08/30/usability-tip-use-verbs-as-labels-on-buttons/
> http://msdn.microsoft.com/en-us/library/aa511268.aspx#respondMainInstruction
>
> I know I can do this with Qt4.5 by explicitly instantiating a QMessageBox
> and then using something like:
>
> QMessageBox messageBox(...);
> messageBox->button(QMessageBox::Yes)->setText("Erase the Hard Disk");
> messageBox->button(QMessageBox::No)->setText("Don't erase the Hard Disk");
> if( messageBox->exec() == QMessageBox::Yes ){
> eraseTheHardDisk();
> }
>
> But at the moment I'm using the (very convenient) static functions
> (QMessageBox::question() et al) so its quite a bit of work to rework all
> my
> code to use non-static message boxes.
>
> Before I decide how to proceed I would like to know if there are plans to
> support customising message box button texts via the the static message
> box
> functions in Qt 4.6 or in the future?
>
> Perhaps there is a cleaner way to do it, but I'm imagining something like:
>
> if( QMessageBox::question( 0, "MyApp", "Do you want to erase the Hard
> Disk?",
> QMessageBox::NamedStandardButtonList()
> << QMessageBox::NamedStandardButton( QMessageBox::Yes,
> "Erase the Hard Disk" )
> << QMessageBox::NamedStandardButton( QMessageBox::No,
> "Don't
> erase the Hard Disk" ),
> /* default= */ QMessageBox::No ) == QMessageBox::Yes ){
>
> eraseTheHardDisk();
> }
>
> Is this planned or should I rewrite to the first way?
>
> Thanks!
>
> Ross.
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended recipient
> and may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
More information about the Qt-interest-old
mailing list