[Kde-bindings] Qyoto - how to Ok/Cancel dialog?

Arno Rehn arno at arnorehn.de
Wed Feb 24 16:19:00 UTC 2010


On Wednesday 24 February 2010 14:06:07 linuxoidoz at yahoo.com.au wrote:
> Hello,
> 
> Here's a C++ example for a two button dialog:
> 
>          int button = QMessageBox::question(this,
>              tr("Confirm Remove"),
>              tr("Are you sure you want to remove \"%1\"?").arg(name),
>              QMessageBox::Yes | QMessageBox::No);
> 
>          if (button == QMessageBox::Yes) {
> 		//do something
>          }
> 
> If I translate it to C#:
> 
> 	int button = QMessageBox.Question(this, "Confirm Remove", "Are you sure
> you want to remove?", QMessageBox.StandardButton.Ok,
> QMessageBox.StandardButton.Cancel);
> 
>          if (button == QMessageBox.StandardButton.Ok) {
> 		//do something
>          }
> 
> it says "Operator `==' cannot be applied to operands of type `int' and
> `Qyoto.QMessageBox.StandardButton".
> 
> I've also tried this part:
> 
> 	int ret = dlg.Exec();
> 	switch (ret) {
> 		case QMessageBox.StandardButton.Ok:
> 		   // Save was clicked
> 		   break;
> 		case QMessageBox.StandardButton.Cancel:
> 		   // Don't Save was clicked
> 		   break;
> 	}
> 
>  same thing: "Cannot implicitly convert type
> `Qyoto.QMessageBox.StandardButton' to `int'. An explicit conversion exists
> (are you missing a cast?)"
Cast the Enum value to an int first.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list