Results 1 to 15 of 15

Thread: A while(1) C function to run in Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    47
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A while(1) C function to run in Qt

    Thanks guys i have found another way to "Threading ", maybe wrongly executed .
    I did it by declaring the "C" function into a function in the cpp file .
    Then i used a Qtimer to connect the timer to the function and start it.

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

    Default Re: A while(1) C function to run in Qt

    Quote Originally Posted by 020394 View Post
    Thanks guys i have found another way to "Threading ", maybe wrongly executed .
    I did it by declaring the "C" function into a function in the cpp file .
    Then i used a Qtimer to connect the timer to the function and start it.
    There is no threading here, timers do not spawn new threads.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2013
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: A while(1) C function to run in Qt

    Try to use the QtConcurrent::run or the QtConcurrent::map instead the QThread.

  4. #4
    Join Date
    May 2013
    Posts
    47
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A while(1) C function to run in Qt

    So when can I use the QTimer ? I am trying to use the QTimer to run a function along with the Gui. Is it the right way to ?

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

    Default Re: A while(1) C function to run in Qt

    A timer is for running some code in a specific moment in time. It is handled by an event like (almost) everything else in Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    May 2013
    Posts
    47
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A while(1) C function to run in Qt

    Quote Originally Posted by wysota View Post
    A timer is for running some code in a specific moment in time. It is handled by an event like (almost) everything else in Qt.
    Isnt It the same as running threads ? For now i am doing a school project with different groups all doing different part . for me i am doing the Gui. I need to integrate the rest of the codes my friends do . EG (Algorithm , Checking of a keypad. etc). Am i able to use QTimer for them since i want them to run at a specific moment of time when i am at the Gui page

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

    Default Re: A while(1) C function to run in Qt

    Quote Originally Posted by 020394 View Post
    Isnt It the same as running threads ?
    No. If you are to eat lunch at 12 o'clock, it doesn't mean at 12 some other instance of yourself is spawned and eats a sandwich but rather you have to stop what you had been doing, take out a sandwich, unwrap it, eat it and then attend your other tasks.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    anda_skoa (22nd July 2013)

  9. #8
    Join Date
    May 2013
    Posts
    47
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A while(1) C function to run in Qt

    I see so threading is always running in the background . But i been using timer to check the current time(Updatiing the time on the Label) , Isnt that considered as threadings?

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

    Default Re: A while(1) C function to run in Qt

    Quote Originally Posted by 020394 View Post
    I see so threading is always running in the background . But i been using timer to check the current time(Updatiing the time on the Label) , Isnt that considered as threadings?
    No. Timers have nothing to do with threading.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. pass member function as argument int template function
    By bibhukalyana in forum General Programming
    Replies: 1
    Last Post: 12th March 2013, 07:05
  2. Replies: 11
    Last Post: 5th September 2012, 20:47
  3. Replies: 4
    Last Post: 2nd August 2012, 07:42
  4. Replies: 3
    Last Post: 25th May 2010, 09:46
  5. Replies: 0
    Last Post: 10th March 2010, 08:13

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
  •  
Qt is a trademark of The Qt Company.