This is my "last version" of the code, i tried different things in both qml and c/c++, but the basic problem remains, how to "stop" my C/C++ application and
wait for the user press "OK" or "Cancel" button, and retrieve the value in my C/C++ code?


I've also tried the other way, instead of QDeclarativeEngine i used QDeclarativeView, i guess it doesn't make a difference in solving this issue?


C/C++
Qt Code:
  1. QDeclarativeEngine *engine = new QDeclarativeEngine();
  2. QDeclarativeComponent component( engine, "modaldialog.qml" );
  3. QObject *myObject = component.create();
  4.  
  5. QGraphicsObject* graphicsObject =qobject_cast<QGraphicsObject *>(myObject);
  6. scene.addItem(graphicsObject);
To copy to clipboard, switch view to plain text mode 

QML modaldialog.qml ( i use the modaldialog component from http://projects.forum.nokia.com/QMLTemplates)
Qt Code:
  1. import QtQuick 1.0
  2. import "component" as Comp
  3.  
  4. Item
  5. {
  6. width: 400; height: 400
  7. // Visual is an item that defines some constants for the application
  8. // look and feel, e.g. the font sizes & colors etc.
  9. Comp.Visual
  10. {
  11. id: visual
  12. }
  13.  
  14. // Example on using ModalDialog component.
  15. Comp.ModalDialog_t2
  16. {
  17. id: dialog_t2
  18.  
  19. // Shown text can be set by modifying "text" property.
  20. //text: "Click OK to Accept this dialog. To send it away, click Cancel."
  21. // Always remember to define the size for the dialog.
  22. anchors.fill: parent
  23.  
  24. // Demonstrating how one could keep application wide variables saved
  25. // in one place and use them conveniently all around the application.
  26. fontName: "Helvetica"
  27. fontColor: "#9DE352"
  28. fontColorButton: "#9DE352"
  29. fontSize: 16
  30.  
  31. // Use these if you would like to change the Button look and feel.
  32. // See Visual.qml how these are defined. Remember to modify also the
  33. // ModalDialog.qml, since this functionality is disabled currently.
  34. // buttonBackground: visual.buttonComponent
  35. // buttonBackgroundPressed: visual.buttonPressedComponent
  36.  
  37. onAccepted:
  38. {
  39. console.log("Dialog accepted signal received!");
  40.  
  41. // I know could call a C/C++function here or send a signal, but, if this modal dialog is to be used/called in several places of C/C++ application
  42. // how i could manage such thing?
  43. }
  44.  
  45.  
  46. onCancelled:
  47. {
  48. console.log("Dialog cancelled signal received.")
  49. }
  50. }
  51.  
  52.  
  53.  
  54. function dialog_type_02()
  55. {
  56. dialog_t2.show();
  57. }
  58.  
  59.  
  60. // The model:
  61. ListModel
  62. {
  63. id: list_model
  64.  
  65. Component.onCompleted: dialog_type_02()
  66. }
  67. }
To copy to clipboard, switch view to plain text mode