Results 1 to 19 of 19

Thread: Fast updation for controls in QT3

  1. #1
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Fast updation for controls in QT3

    I am using QT 3.3 for my application and updating near about 150 line edit boxes. The rate of updation is twice in a second, and this updation will continue for more than 30 minutes which showing some problems like -

    X Error: BadRequest (invalid request code or no such operation) 1
    Major opcode: 255
    Minor opcode: 0
    Resource id: 0x40035e



    MyApplication: Fatal IO error: client killed

    There is no delay between the updation of 2 line edits.

    Thanks in advance.

  2. #2
    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: Fast updation for controls in QT3

    Do you use threads?

  3. #3
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Yes I'm using pthread, I'm passing the main window object (which having 150 line edits) to the thread, and updating the line edits from the threads.

    I have tried using QThread, which also showing the same issue.

  4. #4
    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: Fast updation for controls in QT3

    Read this carefully: http://doc.trolltech.com/3.3/threads.html

    Especially the part that says you can't touch the GUI from a non-GUI thread.
    Last edited by jacek; 8th September 2008 at 14:05. Reason: fixed Qt version in the link

  5. #5
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    I tried with the QThread also, which is not working. I am uploading the sample program, that I have done using QThread. Thanks in Advance .....
    Attached Files Attached Files

  6. #6
    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: Fast updation for controls in QT3

    Could you repeat my previous post with your own words?

  7. #7
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Thanks a lot for that the XLib problems are not coming for QThread. But a new problems arise, if I'm using (for the samples I've attached in my previous post) QThread the main window is not coming properly (It's getting hanged), in the document also I could not get any solution for this, can anybody help me ?

  8. #8
    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: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    if I'm using (for the samples I've attached in my previous post) QThread the main window is not coming properly
    You can't mix threads and GUI.

  9. #9
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    To my orginal problem, can I do parallel GUI updation in QT ? Is there any way to do parallel processing with continuous parallel updation GUI in QT? thanks in advance .

  10. #10
    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: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    To my orginal problem, can I do parallel GUI updation in QT ? Is there any way to do parallel processing with continuous parallel updation GUI in QT?
    You would know that if you read that document I've pointed you to. You can use threads for processing, but only the main thread can do anything with the GUI.

  11. #11
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question Re: Fast updation for controls in QT3

    Quote Originally Posted by jacek View Post
    only the main thread can do anything with the GUI.
    What do you mean by a main thread ? Can I do any semaphore post to that thread ?

  12. #12
    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: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    What do you mean by a main thread ?
    The main thread (a.k.a. the GUI thread) is the one that created the QApplication instance.

    Quote Originally Posted by soumyadeep_pan View Post
    Can I do any semaphore post to that thread ?
    Typical way of communication between worker threads and the GUI thread is to use custom events. QApplication provides some locking mechanism, but custom events are better.

  13. #13
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by jacek View Post
    The main thread (a.k.a. the GUI thread) is the one that created the QApplication instance.
    As I'm creating QApplication instance in main(), so I have to update in that thread (a.k.a Inside main() or any called functions from main()), but to my orginal problem I have to update some controls continuosly, as the following -

    main ()
    {
    QApplication object;

    while (1)
    {
    //Updation for the controls.
    }

    object.exec();
    }

    I assume this algorithm will successfully update controls, but it will be always in while loop and I'll not get any events from the other controls available in the same window. If I'm correct, can anybody suggest a solution for this ? ..thanks in advance ....

  14. #14
    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: Fast updation for controls in QT3

    Use QTimer to fire a slot at given interval. You don't have to update faster than people can see.

  15. The following user says thank you to jacek for this useful post:

    soumyadeep_pan (19th September 2008)

  16. #15
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    ..Thanks a lot for your suggestion. Actually in my application I had nearly 15 pthread, which are updating the GUI, which was the main problem.
    I want to know further is it possible to emit signals from pthreads ? I'have tried but it's showing segmentation fault. Thnaks .......

  17. #16
    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: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    Actually in my application I had nearly 15 pthread, which are updating the GUI, which was the main problem.
    Do you have 15 or more cores in your machine? If not, all those threads just make your application slower.

    Quote Originally Posted by soumyadeep_pan View Post
    I want to know further is it possible to emit signals from pthreads ? I'have tried but it's showing segmentation fault.
    What did you do exactly? You have to use a queued connection.

  18. #17
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    Quote Originally Posted by jacek View Post
    Do you have 15 or more cores in your machine? If not, all those threads just make your application slower.


    What did you do exactly? You have to use a queued connection.
    These many number of threads simply for updation of few controls (512 edit boxes X 4Panles) which is not required at all, so I'm going to remove of all those threads. I want to keep one single pthread which will do all the calcultation in my application and after completing the calculations, it will emits a signal to a slot for controls updation. will it be ok ? If it is correct, then how I can emit a signal from pthread to slot (I already done this in a sample that creating seg fault) ? thanks in advance .........

  19. #18
    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: Fast updation for controls in QT3

    Quote Originally Posted by soumyadeep_pan View Post
    will it be ok ?
    It should be.

    Quote Originally Posted by soumyadeep_pan View Post
    If it is correct, then how I can emit a signal from pthread to slot (I already done this in a sample that creating seg fault) ?
    Make sure you use a queued connection. Do you have to use a pthread instead of QThread? Also could you post that sample program?

  20. #19
    Join Date
    Sep 2008
    Location
    Chennai
    Posts
    36
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Fast updation for controls in QT3

    I am not familiar with the queued connection, I would like to go through this and implement as a queued connection. But, here's the code that creating the seg fault while I'm trying to post any event to SLOT. Thanks in Advance .....
    Attached Files Attached Files

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.