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. get error
Qt 6.11 is out! See what's new in the release blog

get error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.1k 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.
  • A Offline
    A Offline
    Armin
    wrote on last edited by
    #1

    Hi
    I put this code and get error

    void MainWindow::on_pushButton_clicked()
    {
        QDate myDate= ui->dateEdit->date();
        QString dateString = myDate.toString();
        label->setText(dateString);
    
    }
    

    Error:

    C:\Users\armin\Documents\StoMar\mainwindow.cpp:21: error: 'label' was not declared in this scope
    label->setText(dateString);
    ^

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

      Hi,

      It's the same error you already had in your other thread. You don't have any object named label.

      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
      2
      • A Offline
        A Offline
        Armin
        wrote on last edited by Armin
        #3

        Thanks but i create label

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Armin
          wrote on last edited by
          #4

          Thanks guys
          I solved.
          I added ui in my code.

          void MainWindow::on_pushButton_clicked()
          {
              QDate myDate= ui->dateEdit->date();
              QString dateString = myDate.toString();
              ui->label1->setText(dateString);
          
          }
          
          mrjjM 1 Reply Last reply
          1
          • A Armin

            Thanks guys
            I solved.
            I added ui in my code.

            void MainWindow::on_pushButton_clicked()
            {
                QDate myDate= ui->dateEdit->date();
                QString dateString = myDate.toString();
                ui->label1->setText(dateString);
            
            }
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Armin
            Hi
            All you add via Designer is available via UI->
            for the same class.
            Its created when you run
            ui ( new Ui::MainWindow ) {
            ui->setupUi ( this );
            Which is inserted when you create the widget via Designer/Creator
            (in the constructor)

            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