[Interest] Creating and displaying qqmlcomponent inside a class

Adrian Stern adrian.stern at screenfood.com
Wed May 8 16:07:46 CEST 2013


I have an application with different windows showing content. There is no user interaction planned.
Two windows are remote controlled mplayers and two should display some pictures.
The second windows are written in qml. For testing I use the default main.qml.

When I try to create the component and set its visibility to true, I get a SIGSEGV at this position. Debugger shows me that in fact the pointer points nowhere.

int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);
    QQmlEngine engine;
    ContentManager *cm = new ContentManager(0, &engine);
    return app.exec();

ContentManager constructor does only: (where 'e' is QQmlEngine *e)
  dm = new DisplayManager(this, e);

DisplayManager creates image player:
  ip1 = new ImagePlayer(this, e);

ImagePlayer constructor does:
ImagePlayer::ImagePlayer(QObject *parent, QQmlEngine *e) : PlayerBase(parent)
  QQmlComponent comp(e, QUrl("qml/MultiRegionTypePlayer/main.qml"));
  o = comp.create();
  p = qobject_cast<QQuickWindow*>(o);  // p will point nowhere
  p->setVisible(true);   // causes SIGSEGV (even if called in separate method)

Is this at all possible to do? When testet in main method this worked fine. Engine had to be unique but QQmlComponent not.
I would appreciate any lead.

Freundliche Grüsse / Best Regards / Meilleures salutations
Adrian Stern
Diese E-Mail und ihre Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail inklusive Anhänge. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der Inhalte dieser Mail ist nicht gestattet.
This e-mail and any attachments may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail including the attachments. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

More information about the Interest mailing list