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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:07:56+00:00 2026-06-14T15:07:56+00:00

A beginner’s question but actually I’m stuck. I am not allowed to use high-level

  • 0

A beginner’s question but actually I’m stuck. I am not allowed to use “high-level” c++ threading function (nor pthread, nor QThread). However, there are some thread that I should create with winAPI function createThread. And those threads use to change some variables. I want to show these variables every 1 second in a QLineEdit component. So I tried a code like:

    stillWorking = true;
    while(stillWorking){
        ui->editElement->setText(QString::number(getVariableValue()));
        qDebug() << 'running!!!'
        Sleep(1000);
    }

The stillWorking boolean value is set to false when some button is clicked. That’s how I hope to stop this loop. But, when I execute the code, the editElement isn’t updated and the application stop responding. However, the 'running!!!' string is well printed in the debug section every second. So, is there any other way to access and show my variables?

  • 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-14T15:07:57+00:00Added an answer on June 14, 2026 at 3:07 pm

    You should use a QTimer, assuming you’re allowed to (even if you were allowed to use threads). Doing any sort of blocking on the UI thread will not work, it needs to be released for event processing to work, and reacting to clicks needs event processing.

    The Timers page has a bit more info and examples of how to use it. The idea here would be to create a slot that simply does:

    ui->editElement->setText(QString::number(getVariableValue()));
    

    and a repeating timer connected to that slot.

    (This assumes that getVariableValue() is properly synchronised and does indeed see the updated value from that other thread.)

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

Sidebar

Related Questions

Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Question : Beginner Level Code: Pure Javascript I had created a web page in
Beginner question here. I'm going to make a Jquery function that is used to
Level: Beginner In the following code my 'samePoint' function returns False where i am
A beginner question I am sure, but I have just started working with a
Beginner question -- what do you usually use as a multimap? I want a
Beginner question concerning changing the information in a view (and not going to a
Beginner java question, but I cannot understand how call-by-Value ( or Reference ) is
Beginner question: I have a dictionary where the values are lists of (a variable
Beginner rails question: How does one return a file from a controller in rails?

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.