Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:31:24+00:00 2026-05-29T16:31:24+00:00

Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python

  • 0

Just started learning PySide and is having problem with QTimer

I have this

#!/usr/bin/python

from PySide.QtCore import QThread;
from classes import Updater;

if __name__ == "__main__":
    thread = QThread();
    thread.start();

    update = Updater();
    update.moveToThread(thread);
    update.run();

and this

class Updater(QObject):
    def update_mode(self):
        #do something
        pass;

    def run(self):
        timer = QTimer();
        timer.timeout.connect(self.update_mode);
        timer.start(10);

I want my script to do some work periodically using QTimer (wanted to try QSystemAlignedTimer but that looks even more complicated to me for now…). Not sure what is wrong at the moment because I am getting this error

QObject::startTimer: QTimer can only be used with threads started with QThread
QEventLoop: Cannot be used without QApplication
QThread: Destroyed while thread is still running
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:31:24+00:00Added an answer on May 29, 2026 at 4:31 pm

    QTimer, along with all other event based classes, need there to be a QApplication instance.

    In:

    thread = QThread();
    thread.start();
    
    update = Updater();
    update.moveToThread(thread);
    update.run();
    

    First of all, get rid of the semicolons. Python programmers don’t like those.
    If you take a close look at what your code is doing, you are making a QThread, starting it, making an Updater, moving it to the thread, running it, and ending the program. There is no command here telling Python to keep the program running, so it ends, and the QThread complains about being destroyed.

    What you should do is make a QApplication, with something like

    app = QApplication(sys.argv)
    

    and the call app.exec_() to start it. In this case, this is essentially equivalent to time.sleep(9999999999...), but what it actually does is it processes events (signals/slots) endlessly. With time.sleep(9999999999...), QTimers will never do anything when they time out.

    As a QApplication is an infinite loop, you will have to manually exit within your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning C++ (coming from Java ) and am having some serious
I just started learning Java and I'm having trouble formatting string. In the problem
I just started learning C++ couple of weeks ago. So now I have this
I just started learning C++ and I wrote this sample program from the text
Just started learning Haskell. I have an empty source file with this inside: pe
Just started learning Jquery - here's my problem: I have six divs on a
We just started learning about class inheritance and attribute lookup in python. I have
I just started learning python and django and I have a question. I got
I just started learning C but I don't understand this part of the code.
I have just started learning Erlang and am trying out some Project Euler problems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.