Results 1 to 4 of 4

Thread: Creating a dynamic QML component from a non Qt thread

  1. #1
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Creating a dynamic QML component from a non Qt thread

    Hi All,

    My application has a qml view. I'm creating a dynamic component for a messagebox developed in QML using QQmlComponent.

    I have a non-Qt class which needs to create this dynamic component on the the qml view.

    However, I get this error that can't create this component on the main thread.

    Kindly suggest how can I create this component on a non-qt thread to display on the qt thread.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating a dynamic QML component from a non Qt thread

    The other thread needs to send a signal or event to the main thread which then creates the component.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a dynamic QML component from a non Qt thread

    Thanks anda_skoa for the suggestion...

    Since it's not a qt class emitting signals is ruled out.. Could you explain how do i pass an event to the main thread to create this component?

    Kindly advice

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating a dynamic QML component from a non Qt thread

    You can either user QMetaObject::invokeMethod with Qt::QueuedConnection to invoke a lot on an object in the main thread or use QCoreApplication:ostEvent() to send a custom event to an object in the main thread.

    Cheers,
    _

Similar Threads

  1. Replies: 10
    Last Post: 1st August 2014, 06:50
  2. Replies: 3
    Last Post: 25th September 2011, 14:44
  3. Creating thread for each function of a class
    By Astrologer in forum Qt Programming
    Replies: 10
    Last Post: 19th April 2010, 18:34
  4. Replies: 16
    Last Post: 7th October 2009, 08:17
  5. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.