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 6778399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:15:42+00:00 2026-05-26T16:15:42+00:00

Hi i am implementing a simple threaded GUI application in QT 4.6.2. I am

  • 0

Hi
i am implementing a simple threaded GUI application in QT 4.6.2. I am using QThread without subclassing it. I have made a call to the usleep() function in my start() function this however results in freezing of the GUI. How do i get around this. Below is the code

#ifndef ECGREADER_H
#define ECGREADER_H
#include<QObject>
class ecgreader : public QObject
{
    Q_OBJECT

public:
    ecgreader(QObject *parent=0);
    ~ecgreader();
public Q_SLOTS:
    void start();
Q_SIGNALS:
    void finished();
};
#endif // ECGREADER_H

Below is the start() function

void ecgreader::start()
{
   int i= system("ls>output.txt");
   SLEEP(10000);
   if(i==0)
   {
       emit finished();
   }
}

finally the call to start is made here

void Application::onbtnclicked()
{
    QThread* thread=new QThread;
    ecgreader* reader=new ecgreader;
    reader->moveToThread(thread);
    connect(thread,SIGNAL(started()),reader,SLOT(start()));
    connect(reader,SIGNAL(finished()),thread,SLOT(quit()));
    connect(reader,SIGNAL(finished()),reader,SLOT(deleteLater()));
    connect(reader,SIGNAL(finished()),thread,SLOT(deleteLater()));
    reader->start();
}

Please help

  • 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-26T16:15:43+00:00Added an answer on May 26, 2026 at 4:15 pm

    You have two problems: first you created the thread, but you never started it. Second you are directly calling start() on your reader instead of emiting a signal.

    I think what you meant was to call thread->start() instead of reader->start():

    void Application::onbtnclicked()
    {
        QThread* thread=new QThread;
        ecgreader* reader=new ecgreader;
        reader->moveToThread(thread);
        connect(thread,SIGNAL(started()),reader,SLOT(start()));
        connect(reader,SIGNAL(finished()),thread,SLOT(quit()));
        connect(reader,SIGNAL(finished()),reader,SLOT(deleteLater()));
        connect(reader,SIGNAL(finished()),thread,SLOT(deleteLater()));
        thread->start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a simple threaded application in which I have a server thread, and
I am implementing a simple drop-down using hiccup: ;DATASET/CREATE (defn get-cols-nms [table] This function
I tried implementing a simple web service into an asp.net application using the tutorial
i am implementing the simple bubble sort algorithm using CUDA, and i have a
I'm implementing a simple update mechanism for an application I'm writing the last part
I am implementing a simple version of a linux shell in c. I have
Ok...... I'm implementing a simple OpenGL ES application on the iPhone and I recently
I am implementing a quite simple state-machine order processing application. It is a e-commerce
I am implementing a very simple file database. I have 2 basic operations: void
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in

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.