Results 1 to 3 of 3

Thread: application help

  1. #1
    Join Date
    Jan 2025
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default application help

    Hi everyone,

    I'm trying to create a Qt application to run GPIOs on the Raspberry Pi with sensors.

    I'm having trouble.

    The interface works fine.
    I have a screen (mainwindow class) with 5 QLCDNumbers that display temperatures read from a "temperatures" file (QSetting class) every 10 seconds using Qtimer.
    This screen also displays animated GIFs based on the GPIOs.

    mainwindow launches threadSondes (QThread class) and launches gainable (Gainable (gpios) class).

    threadSondes writes the temperatures of the 5 sensors to "temperatures" (QSetting class) every 15 seconds using Qtimer.

    The ducted system starts functions (cooling, heating, and heatwave) and launches a QTimer every second to update the functions.

    My problem is that the thread's QTimer blocks my animated GIFs while the temperatures of the 5 sensors are being written.

    And in my terminal, I have:

    QObject::startTimer: Timers can only be used with threads started with QThread

    Can anyone give me a procedure? Thanks.

    here is my github link
    https://github.com/ludoiphone/QtGainable

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,311
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: application help

    QObject::startTimer: Timers can only be used with threads started with QThread
    QTimer requires an event loop, since it uses signals and slots to communicate its status. That means you either have to start it in the main application (QApplication-based instance) or in a thread started by QThread. If you are trying to use QTimer somewhere else, it will not work.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2025
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: application help

    Okay, thanks.

    I think I'm doing it wrong with QTimer and QThread.

    I need to find the right order. I've tried a lot of things but can't get it right (especially with my sensors).

    I'm trying to get a graphical interface (mainwindow).

    I need to read the temperature file (QSetting) every 10 seconds (QTimer), all the time.

    Furthermore, I need to write the temperature file (QSetting) every 15 seconds (QTimer), all the time.

    And my pin management (GPIOs) needs to work every 1 second (QTimer), or not if possible (with slots and signals maybe), all the time.

    And in my code on GitHub, it works.

    But I encounter a problem when I write my temperatures via the sondes.cpp class
    in temperatures(QSetting)

    When I use the Qtimer without the probes thread class and with the run() function, I set a sleep(10) value, it works, but after a while my probes disconnect from the Raspberry Pi.

Similar Threads

  1. Need help with a code please help :D
    By Sean11 in forum Qt Programming
    Replies: 7
    Last Post: 22nd September 2017, 01:53
  2. help,who could help me to compile qt project
    By derekli in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2014, 15:27
  3. Replies: 13
    Last Post: 10th February 2014, 14:05
  4. Replies: 5
    Last Post: 26th June 2007, 13:10
  5. Making some simple help for my application
    By Godlike in forum Newbie
    Replies: 9
    Last Post: 21st April 2006, 18:43

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.