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
QtWS25 Last Chance

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.3k Views
  • 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 20 Nov 2018, 05:29 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 20 Nov 2018, 17:32 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 22 Nov 2018, 02:49 last edited by
        #3

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 22 Nov 2018, 04:15 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 22 Nov 2018, 19:28 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
            • D Offline
              D Offline
              dheerendra
              Qt Champions 2022
              wrote on 25 Nov 2018, 06:39 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

              J 1 Reply Last reply 26 Nov 2018, 08:31
              0
              • D dheerendra
                25 Nov 2018, 06:39

                @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();
                }
                
                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 26 Nov 2018, 08:31 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
                • D Offline
                  D Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on 26 Nov 2018, 08:34 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

                  J 1 Reply Last reply 26 Nov 2018, 08:35
                  0
                  • D dheerendra
                    26 Nov 2018, 08:34

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

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 26 Nov 2018, 08:35 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
                    • D Offline
                      D Offline
                      dheerendra
                      Qt Champions 2022
                      wrote on 26 Nov 2018, 08:36 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

                      2/10

                      20 Nov 2018, 17:32

                      8 unread
                      • Login

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