[Qt-interest] Some questions about QML

kai.koehne at nokia.com kai.koehne at nokia.com
Tue Nov 3 15:55:23 CET 2009


ext Jabot Corentin wrote:
> I have a qml UI with many buttons: How can I call c++
> treatments when I click on those buttons ?
>
> I project to design an application where the UI is in QML (so
> I can change the UI look and fell easily) and the core
> features are in c++ .
> How I'm suppose to achieve that ?


The most straightforward way is to declare a top level signal:

Button.qml:
import Qt 4.6

Rectangle {
  id : root
  signal pressed

  width: 100
  height: 40
  Text {
    anchors.fill:parent
    text: "Click me!"
  }
  MouseRegion {
    anchors.fill:parent
    onClicked: {
      root.button1Pressed();
    }
  }
}


You can then connect to this signal in your C++ program:

  // ...
  QObject *rootItem = qmlView->root();
  connect(rootItem, SIGNAL(pressed()), this, SLOT(onPressed()))
  // ...

> About security :
> 
> Suppose I declare a password field in a qml UI. If someone
> modify this qml and load a resource with  a url like
> http://foo.com/?password={ content of the password field }
> and the distribute It to users, there will be a lot of
> account hacking...that's could be a problem ! So, is there
> solutions to avoid that ?

Well ... I am tempted to say that if 'somebody' is able to modify your qml you are lost anyway, aren't you? Anyhow, probably you can achieve what you are aiming at by setting your own QNetworkAccessManager from C++.

Regards

Kai


-- 
Kai Köhne
Software Engineer
Nokia, Qt Development Frameworks

Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori




More information about the Qt-interest-old mailing list