Thread: anyone intimately familiar with QT?

  1. #1
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838

    anyone intimately familiar with QT?

    i posted a question on a qt forum, but i am impatient, and thought perhaps some here might know the answer

    update widget from separate thread - Qt Centre Forum

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > but i am impatient
    How To Ask Questions The Smart Way
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Tried calling repaint() on the widget in question?

  5. #5
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    yes. it fails a thread-safety assertion when i try to call repaint(...) from my image acquisition thread.

    it just doesn't do anything if i call update.

    the solution i've come up with so far is to have paint event recurse by calling update at the end of the method, but that is a bit of a resource hog. if i am sampling at 1Hz, i am wastefully updating the same image many times.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You probably need to emit a signal from your worker thread to the main thread, the have the main thread update the widget. I don't know much about QT though, so it's just a guess.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    bithub is right. The Qt way for cross-thread communication is to connect a signal on an object that belongs to the sender thread to a slot on an object that belongs to the receiver thread.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    got it. i was stupidly trying to emit a slot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. QT 4 and MSVC 6.0. Need help/
    By LMZ in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2006, 03:57 PM
  2. Simple Qt Programming Question
    By Reisswolf in forum Linux Programming
    Replies: 1
    Last Post: 05-23-2006, 01:26 PM
  3. QT or others for the beginning linux programmer
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 09-12-2003, 01:17 PM
  4. First QT App
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-26-2002, 09:30 AM
  5. EASY GUI development.. like with Qt?
    By rezonax in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2001, 01:18 PM