Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. value not updated on gui
Qt 6.11 is out! See what's new in the release blog

value not updated on gui

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shashi prasad
    wrote on last edited by
    #1

    Hi

    i am updating a value on GUI in QT in single thread using below code

    Label[Index]->setText(time);
    this->update();
    qApp->processEvents();
    qDebug()<<"setting--------------------------------1"<<time<<"index=="<<Index<<">>>>>>>>>>>"<<Label[Index]->text();

    first time value updated on gui but later it is not updating on gui.

    value is set on label correctly, checked using code Label[Index]->text().

    but it is not updating on gui.

    why it is not updating on GUI, please suggest me what i have to do.

    Thanks
    Shashi

    Venkatesh VV jsulmJ 2 Replies Last reply
    0
    • S shashi prasad

      Hi

      i am updating a value on GUI in QT in single thread using below code

      Label[Index]->setText(time);
      this->update();
      qApp->processEvents();
      qDebug()<<"setting--------------------------------1"<<time<<"index=="<<Index<<">>>>>>>>>>>"<<Label[Index]->text();

      first time value updated on gui but later it is not updating on gui.

      value is set on label correctly, checked using code Label[Index]->text().

      but it is not updating on gui.

      why it is not updating on GUI, please suggest me what i have to do.

      Thanks
      Shashi

      Venkatesh VV Offline
      Venkatesh VV Offline
      Venkatesh V
      wrote on last edited by
      #2

      @shashi-prasad

      Have you set parent to the label as this widget?
      here you are updating widget if label has not set parent, update wont reflect to label.
      label.setParent(this);

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shashi prasad
        wrote on last edited by
        #3

        @Venkatesh-V said in value not updated on gui:

        label.setParent(this);

        yes i have set label as

        Label[i] = new QLabel(this); but its not working

        1 Reply Last reply
        0
        • S shashi prasad

          Hi

          i am updating a value on GUI in QT in single thread using below code

          Label[Index]->setText(time);
          this->update();
          qApp->processEvents();
          qDebug()<<"setting--------------------------------1"<<time<<"index=="<<Index<<">>>>>>>>>>>"<<Label[Index]->text();

          first time value updated on gui but later it is not updating on gui.

          value is set on label correctly, checked using code Label[Index]->text().

          but it is not updating on gui.

          why it is not updating on GUI, please suggest me what i have to do.

          Thanks
          Shashi

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @shashi-prasad said in value not updated on gui:

          why it is not updating on GUI, please suggest me what i have to do

          I would suggest to provide more information as with what you provided it is actually impossible to say why it behaves like this.
          Where and when is this code executed? Are you sure it is executed second time at all?
          Did you put another QLabel in Label[Index] after first call?
          Show your code.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shashi prasad
            wrote on last edited by
            #5

            std::thread commandExecutor(TimeThread);// created thread for updating playback commandExecutor.detach();

            Label is created in constructor only before this thread

            void Mode::TimeThread()
            {
            int Index=0;
            //time is calculated here in qstring
            Label[Index]->setText(time);
            this->update();
            qApp->processEvents();

            }

            jsulmJ 1 Reply Last reply
            0
            • S shashi prasad

              std::thread commandExecutor(TimeThread);// created thread for updating playback commandExecutor.detach();

              Label is created in constructor only before this thread

              void Mode::TimeThread()
              {
              int Index=0;
              //time is calculated here in qstring
              Label[Index]->setText(time);
              this->update();
              qApp->processEvents();

              }

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @shashi-prasad As I wrote in another thread: do not update UI in other thread than main thread! This is not going to work! UI must be updated in the main thread.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved