Results 1 to 4 of 4

Thread: QTimer and QThread in Qtopia 4.2.0

  1. #1
    Join Date
    Dec 2006
    Posts
    11
    Thanks
    1
    Qt products

    Question QTimer and QThread in Qtopia 4.2.0

    The case is I've got two event loops in application, one is Qtopia's GUI's event loop, the other is glib's event loop for network.

    In Qtopia 2.2.0, I cannot use QThread because of our development environment configuration. So I use QTimer. When it's timeout,
    Qt Code:
    1. g_main_context_iteration(g_main_context_default(), FALSE);
    To copy to clipboard, switch view to plain text mode 
    will be called.

    Now in Qtopia 4.4.0, when I port this code, compile, and run, It says QTimer should be used in thread started with QThread. Does that mean I must start a timer in an event loop? If I use one thread for GUI event loop, the other for listening network events to give user prompts, will this work?

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

    Default Re: QTimer and QThread in Qtopia 4.2.0

    Hmm.... Why do you need a separate event loop for networking? Qt4 uses glib event loop itself (if you compile it that way), so you are using a single loop even now. I just don't see the point of separate event loops... Could you explain?

  3. #3
    Join Date
    Dec 2006
    Posts
    11
    Thanks
    1
    Qt products

    Default Re: QTimer and QThread in Qtopia 4.2.0

    The library this application used is based on glib. It need an event loop to keep monitoring network and callback application. In Qtopia, QtopiaApplication::exec() maybe GUI event loop. I'm not sure this could also monitor network.

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

    Default Re: QTimer and QThread in Qtopia 4.2.0

    Qt/Qtopia contains networking classes. I'm sure you can use them instead of the glib dependency. But regardless of that if you use a glib-enabled Qt, the Qt event loop should work within the glib event loop without any special tricks to activate the loop. Just call QApplication::exec() and the loops should cooperate. At least that's how I understand it. There is even an article about it somewhere on Trolltech Labs or Qt Quarterly - you can try to dig it out...

Similar Threads

  1. QTimer and QThread
    By TheKedge in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2006, 14:52
  2. Qthread n QTimer Problem
    By quickNitin in forum Qt Programming
    Replies: 5
    Last Post: 8th June 2006, 14:12
  3. Replies: 6
    Last Post: 17th March 2006, 17:48

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.