Results 1 to 3 of 3

Thread: Threading and plotting graph in same program.

  1. #1
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Threading and plotting graph in same program.

    Hi everyone,

    Is it possible to run a thread and plotting the graph simultaneously ? i mean i have a thread which reads data every one second and based upon the datas i need to plot a graph. is this possible ?i tried this ,but was not successfull. the thread reads the datas correctly,but i cant see the graph. when i comment the thread , the graph is being displayed ?

    can anybody provide suggestions or solutions for this ?

    thanks in advance,

    saravanan.

  2. #2
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Threading and plotting graph in same program.

    Ok, let me put the question this way:

    i have any application where i'l construct a thread and monitor the data from the serial port in the thread::run() function. if there is data in the serial port i'l read it and create a qwt plot object and display the data. is this possible ?

    i read in the qt docs (http://doc.trolltech.com/3.3/threads.html) that we should not create a widget inside the thread ? Is this the reason why i can't see the qwt plot widget ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Threading and plotting graph in same program.

    Quote Originally Posted by sar_van81 View Post
    i read in the qt docs (http://doc.trolltech.com/3.3/threads.html) that we should not create a widget inside the thread ? Is this the reason why i can't see the qwt plot widget ?
    Yes, if the docs say that something won't work, it won't work. In Qt you can use widgets only in the GUI thread (aka main thread).

    In your situation you can use custom events to send processed data from the thread to the GUI.

    http://doc.trolltech.com/3.3/qcustomevent.html

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.