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. Qt Creator 4.6.2 on MacOS High Sierra setText() not working
Forum Updated to NodeBB v4.3 + New Features

Qt Creator 4.6.2 on MacOS High Sierra setText() not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 5 Posters 1.4k Views 2 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.
  • V Offline
    V Offline
    valveCorp
    wrote on last edited by
    #1

    I am doing a very simple test. If a button is pressed, a text label is changed to something. 0_1542691634399_Screen Shot 2018-11-20 at 12.26.34 AM.png

    The qDebugs are printing fine, meaning the connections are ok, but the setText method is just not doing anything? The code compiles fine.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      and you are positive that the label has a size and
      not ultra small or anything like that ?
      What if you place a label in Designer and set its text ?

      1 Reply Last reply
      2
      • V Offline
        V Offline
        valveCorp
        wrote on last edited by
        #3

        I can see it fine in design mode. setText() won't change the size, right?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          It sets it. It does not refresh. Hide and show it again. It will work. Seems like a bug to me as well.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            What version of Qt are you using ?

            Can you provide a complete minimal example that shows that behavior ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by dheerendra
              #6

              @valveCorp Just call repaint() after updating the text. It should work.

              MyWidget::MyWidget(QWidget *parent) :
                  QWidget(parent),
                  ui(new Ui::MyWidget)
              {
                  ui->setupUi(this);
                  ui->label->setText("Dheerendra");
                  this->m_lab = new QLabel("pthinks.com");
                  ui->verticalLayout->addWidget(m_lab);
              }
              void MyWidget::on_pushButton_clicked()
              {
                 qDebug() << Q_FUNC_INFO << endl;
                 this->m_lab->clear();
                 this->ui->label->setText("Dheeru");
                 this->m_lab->setText("http://www.pthinks.com");
                 this->repaint();
              }
              

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              jsulmJ 1 Reply Last reply
              0
              • dheerendraD dheerendra

                @valveCorp Just call repaint() after updating the text. It should work.

                MyWidget::MyWidget(QWidget *parent) :
                    QWidget(parent),
                    ui(new Ui::MyWidget)
                {
                    ui->setupUi(this);
                    ui->label->setText("Dheerendra");
                    this->m_lab = new QLabel("pthinks.com");
                    ui->verticalLayout->addWidget(m_lab);
                }
                void MyWidget::on_pushButton_clicked()
                {
                   qDebug() << Q_FUNC_INFO << endl;
                   this->m_lab->clear();
                   this->ui->label->setText("Dheeru");
                   this->m_lab->setText("http://www.pthinks.com");
                   this->repaint();
                }
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @dheerendra I'm wondering why repaint would be needed after updating QLabel text?

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

                1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #8

                  @jsulm It does not work if you no repaint(). Even update() is not working. Only repaint() works.

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  jsulmJ 1 Reply Last reply
                  0
                  • dheerendraD dheerendra

                    @jsulm It does not work if you no repaint(). Even update() is not working. Only repaint() works.

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

                    @dheerendra But QLabel should repaint when its text is changed, shouldn't it?

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

                    1 Reply Last reply
                    0
                    • dheerendraD Offline
                      dheerendraD Offline
                      dheerendra
                      Qt Champions 2022
                      wrote on last edited by
                      #10

                      @jsulm true. But it is not working. It is work-around.

                      Dheerendra
                      @Community Service
                      Certified Qt Specialist
                      http://www.pthinks.com

                      1 Reply Last reply
                      0

                      • Login

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