Results 1 to 5 of 5

Thread: QTableWidget Design & Thread Safety Question

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget Design & Thread Safety Question

    Hey guys,

    I am writing a simple app that tests various ODBC calls and SQL statements to analyze performance. It can spawn many threads... each thread, for example, could run a query over and over again, gathering statistical data for the run.

    I have a QTableWidget that I am wanting to use to view this data. Each threads gets its own row in the table.

    I was wonder if it was safe to have each thread update its own row. I think it would be safe since it is essentially a node based container and I am only updating the values of existing nodes.

    Would it be better if I have a timer on my main thread that polls data from my worker threads so that it would be responsible for updating the QTableWidget instead of each thread updating their own row?

  2. #2
    Join Date
    Jun 2006
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QTableWidget Design & Thread Safety Question

    use post event

  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: QTableWidget Design & Thread Safety Question

    or a signal and a queued connection.

  4. #4
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget Design & Thread Safety Question

    I am just curious... is it a bad idea for different threads to modify data in a QTableWidget's QTableWidgetItem if each thread never accesses another threads QTWI?

    I have a QTimer that is running, I was thinking that is what I could use to repaint the table.
    It just sounds like this is the most efficient way in terms of CPU load. It would give the user a chance to specify a refresh increment too. You would lose a nice looking asynchronous effect, but other than that...

  5. #5
    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: QTableWidget Design & Thread Safety Question

    Quote Originally Posted by bpetty View Post
    I am just curious... is it a bad idea for different threads to modify data in a QTableWidget's QTableWidgetItem if each thread never accesses another threads QTWI?
    It's a Very Bad Idea(tm). All widgets belong to the GUI thread and it's very jealous about it.

    Quote Originally Posted by bpetty View Post
    I have a QTimer that is running, I was thinking that is what I could use to repaint the table.
    You can use QTimer to poll the threads or you can make threads send signals/event when data changes. Everything depends on the number of updates per second. If thread will send more than 25 signals per second the polling aproach might be more efficient. On other hand threads can send only changed data, while with polling approach you will have to check all the data.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Replies: 10
    Last Post: 20th March 2007, 22:19
  3. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02

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.