Results 1 to 8 of 8

Thread: QWidget::update() qeustion

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: QWidget::update() qeustion

    Yes.

    Actually many dialogs are updated by threads.

    Is there any thing to consider to update GUI for the multiple threads?

    Thanks.

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

    Default Re: QWidget::update() qeustion

    You can't access GUI objects (dialogs included) from within worker threads.

  3. #3
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Wink Re: QWidget::update() qeustion

    I cannot understand I can't access GUIs in worker thread.

    CUIGOCIImgStatus is a class which inherits QWidget. It also includes <ui_gociimgstatus.h> generated by qmake.

    I updates by using a thread which check status of other system.
    If status is changed,
    I set values in member variables in CUIGOCIImgStatus to update , then I call updates().
    Then paintEvent() is called.
    CUIGOCIImgStatus objects is a global variable to share.
    It is created by main thread but is updated by only one other threads.

    Usually, this works well.

    but 1 out of 10, segment fault happens.

    anything wrong??

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

    Default Re: QWidget::update() qeustion

    Quote Originally Posted by tanki95 View Post
    I cannot understand I can't access GUIs in worker thread.
    Well... you just can't.

    I updates by using a thread which check status of other system.
    If status is changed,
    I set values in member variables in CUIGOCIImgStatus to update , then I call updates().
    Sorry, that's forbidden.

    Usually, this works well.
    Yes... usually That's the key word here.

  5. #5
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: QWidget::update() qeustion

    Ok... I think I understand what you meant.

    You mean I should call 'update()' in the main GUI thread?

    But how do I call update() in the main GUI thread if the content of the GUI is changed from the other thread?

    If I use timer thread by using QTimer, it is also forbidden. right?

    Do you have any suggestion for the current my situation??

    Thank you very much for your reply.

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

    Default Re: QWidget::update() qeustion

    Quote Originally Posted by tanki95 View Post
    You mean I should call 'update()' in the main GUI thread?
    Yes, that too.

    But how do I call update() in the main GUI thread if the content of the GUI is changed from the other thread?
    Use signals and slots or custom events.

    If I use timer thread by using QTimer, it is also forbidden. right?
    I'm not sure I understand what you mean. You can use timers in other threads.

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
  •  
Qt is a trademark of The Qt Company.