[Qt-qml] Setting the source with a click on QML component
Alan Alpert
alan.alpert at nokia.com
Mon Oct 3 03:46:22 CEST 2011
On Fri, 30 Sep 2011 19:56:34 ext Bartosh Wroblevksy wrote:
> Thank you Girish, I guess we were looking for a solution where it is the
> C++ code that drives the loading of the qml files. Our solution keeps
> crashing after a setSource is executed. With your clicker.qml , we would
> like to implement something like this:
>
> Rectangle {
> signal change();-- MouseArea { anchors.fill: parent
> onClicked:{ container.change() } }---}
> DeclarativeView::DeclarativeView(QWidget* parent)
> :QDeclarativeView(parent){
> setSource(QUrl::fromLocalFile("./clicker.qml"));
> QObject *test= dynamic_cast<QObject*>(rootObject ());
> QObject::connect(test, SIGNAL(change()), this, SLOT(doit()));}
> void DeclarativeView::doit(){
> setSource(QUrl::fromLocalFile("./another.qml"));}
>
It sounds like the problem is that you're deleting the QML scene while in the
middle of the signal handler. If you add a slight delay between the change
signal and the setSource call (for example, have doIt() be
QTimer::singleShot(0, this, SLOT(reallyDoIt()));) then it shouldn't crash.
--
Alan Alpert
Senior Engineer
Nokia, Qt Development Frameworks
More information about the Qt-qml
mailing list