January 25, 2012

Cg_Artist Cg_Artist
Lab Rat
20 posts

Can QML Viwer be run on a seperate Thread?

 

As I try and wrap my head around QML and how to use it in my cpp application I had a few questions. In my particular situation I am trying to use QML to build the interface for a plugin that I have developed for another application (Maya). I ran a test using:

  1. QDeclarativeView view;
  2. view.setSource(QUrl("qrc:/myCustomUI.qml"));
  3. view.show();

This resulted in my allowing me to my UI for the duration of time that my function ran. However, as you can imagine this was not my desired result. So I guess my questions are what the best approach would be run a QML interface in a plugin for another application and am I right in thinking that I would have to run the UI on a separate thread from my main application. Anyway I just thought I would ask here first before I dig in to deep, hoping that someone might be able to provide some direction on how to pull this off.

2 replies

January 25, 2012

Cg_Artist Cg_Artist
Lab Rat
20 posts

To answer part of my own question I some how missed using the “app.exec()” at the end of my function. Now it remains on the screen.

  1. QDeclarativeView view;
  2. view.setSource(QUrl("qrc:/myCustomUI.qml"));
  3. view.show();
  4. return app.exec();

Still looking in the multi-threading aspect. Will post what I discover.

January 26, 2012

Volker Volker
Ant Farmer
5428 posts

QDeclarativeView, as every other GUI class, must live in the main thread. There is no way to circumvent this and move it to another thread.

 
  ‹‹ Qt dbus for multiple out parameters      SSPI support ››

You must log in to post a reply. Not a member yet? Register here!