get error



  • 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);
    ^


  • Lifetime Qt Champion

    Hi,

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



  • Thanks but i create label



  • 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);
    
    }
    

  • Qt Champions 2016

    @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)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.