[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KMessagebox::createKMessageBox() doesn't return proper button codes
From:       Adriaan de Groot <groot () kde ! org>
Date:       2004-10-06 15:44:36
Message-ID: 200410061744.42300.groot () kde ! org
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached itty bitty program queries the user twice - once with a dialog 
constructed through createKMessageBox, and once with questionYesNoCancel.  
Here, I get (for instance) output like this:

tester: WARNING: Return 256
tester: WARNING: Return 3

after clicking on the "yes" button both times. I'd expect it to return the 
same value in both cases. The reason this is not so is clear: 
createKMessageBox returns the button ids from the KDialog directly, while 
questionYesNoCancel returns a translated button code. Since both methods have 
the same return type int and the return value is undocumented, it's a bit 
confusing. If there's a docs guru who feels like frobbing this , please do so 
- -- otherwise, if no objections, I'll add a blurb myself.

- -- 
Don't worry, 't ain't no shame to be stupid - ol' mouse.
    GPG: FEA2 A3FE Adriaan de Groot
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQFBZBLqdqzuAf6io/4RAizeAJwP6PCkw4XtbGQir98QSH0C5vi7lgCfeizM
5Eeh1iRJ7kHT318Vrjb+G5I=
=j9eH
-----END PGP SIGNATURE-----

["t.cc" (text/x-c++src)]

#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdialogbase.h>
#include <kmessagebox.h>
#include <kdebug.h>

int main(int argc, char**argv)
{
	KCmdLineArgs::init(argc, argv, "tester", "tester", "tester", "tester");
	KApplication::addCmdLineOptions();
	KApplication a;
	KDialogBase *dialog = new KDialogBase( "Question" );
	int r=KMessageBox::createKMessageBox(dialog,
		QMessageBox::Question,
		"Do you use KDE?",
		QStringList(),
		QString::null,
		0L,
		0);

	kdWarning() << "Return " << r << endl;

	r = KMessageBox::questionYesNoCancel(0L,
		"Do you use GNOME?");
	kdWarning() << "Return " << r << endl;
}



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic