Results 1 to 4 of 4

Thread: How to show a QWidget from a different thread without using signal?

  1. #1
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to show a QWidget from a different thread without using signal?

    I need to show some widgets from the second thread. These codes do not exist in a subclass of QObject, so I cannot use signal and slot to accomplish it. I was thinking about using events but I didn't see any suitable event. I've also tried to use QMetaObject::invokeMethod() but it didn't work either. It returns true but nothing happens.

    Could anyone give me some suggestions?
    Thanks!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show a QWidget from a different thread without using signal?

    You can use user events. Subclass QEvent and give it a suitable ID.
    You can also attach custom data to user events.

  3. The following user says thank you to marcel for this useful post:

    topher (28th February 2008)

  4. #3
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to show a QWidget from a different thread without using signal?

    I'm wondering if it is possible to use something pre-existed in QT framework for this.
    The reason I want to avoid user events is that it implies reimplementation of event handler for this event. It seems to be a huge work when there are a lot of widgets. Am I right on this?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to show a QWidget from a different thread without using signal?

    If you want something "pre-existed" then use signals

    If you need it for many widgets, I suggest you implement a special object that will be calling show() for you on desired widgets when it receives the custom event. This way you'll only have to implement the solution for one object and it will work for all of them.

  6. The following user says thank you to wysota for this useful post:

    topher (28th February 2008)

Similar Threads

  1. Close a thread with a signal
    By victor374 in forum Qt Programming
    Replies: 1
    Last Post: 30th November 2007, 06:33
  2. Thread freezing GUI
    By TheGrimace in forum Qt Programming
    Replies: 26
    Last Post: 27th June 2007, 15:57
  3. creating treeWidgetItem using emitted signal from thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:37
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

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.