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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:20:18+00:00 2026-06-13T06:20:18+00:00

I use a timer to emit a signal and call a slot function which

  • 0

I use a timer to emit a signal and call a slot function which updates the UI according to new data.

I’ve calculated the time to run that function as being quite short. When the timer is set to 1000ms, the UI responds quite slow.

I tried to move that functionality to a thread but I’m finding it difficult since a lot of the functionality needs to access the UI class’s protected values.

I’m going to try moving the timer to another thread and leave the update functionality in the UI class (main window) but I don’t know if it will help.

Why is the timer causing the UI to be slow and unresponsive? Will a thread be lighter and consume less CPU time? How can I fix this?

    initTimer()
    {
        refreshTimer = new QTimer(this);
        connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshDisplay));
        refreshTimer->start(1000);
    }

refresh slot function called every 1000ms:

    void refreshDisplay()
    {
        ui->tableWidget->setUpdatesEnabled(false);

        for(int queue_i = size_1, index = 0; queue_i >= 0; queue_i--, index++)
        {
            LogInfoItem* logItem = (LogInfoItem*)logDisplayQueue.at(queue_i);

            QString BITS_str = bits2Hexs(logItem->BITS);


            ui->tableWidget->item(index, 0)->setText(logItem->time);//time
            ui->tableWidget->item(index, 1)->setText(logItem->name);//name
            ui->tableWidget->item(index, 2)->setText(BITS_str);//BITS

            if(queue_i == oldRowItemNo)ui->tableWidget->selectRow(index);
        }

        ui->tableWidget->setUpdatesEnabled(true);

        Q_FOREACH(Page* p, PageInfoList)
        {
            p->refresh();
        }

        Q_FOREACH(IconLabel* icl, iconLabelList)
        {
            icl->refresh();
        }
    }

What ‘refresh()’ does is just changing icons and texts in the ui according to the data inside. Besides, i’ve made the data static, but still cannot fix it.
(I’ve tested the function, almost no time consuming…)

  • 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-06-13T06:20:19+00:00Added an answer on June 13, 2026 at 6:20 am

    Thank you, I have used your mehods and finally find the cpu eater, it is setIcon function . I add an if statement before it, and wll not call it if data not changed. Thank you, everyone!

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

Sidebar

Related Questions

I'm trying to use a timer in C# to run a method at an
I'm trying to move a sprite in a QGraphicsView. I use : connect(timer, SIGNAL(timeout()),
I'm trying to use Rails(2)'s to_json model serializing mechanism to emit some data from
Timers.Timer to create StopWatch. I use Timer.Elapsed to handle event that display time after
I'm trying to use timer to refresh an image from the internet. This is
I am using MSP430F5418 with IAR EW 5.10 . I want to use Timer
I'm trying to use a timer to schedule a recurring event in an application.
I am trying to use Swing Timer and I wanted to start from a
What is the best approach in using a timer. Use a System.Timer.Timer class or
Can we use SPSecurity.RunWithElevatedPrivileges in SharePoint timer jobs? Under whose identity will the timer

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.