Error for get date
-
Hi
I write this code but get error :void MainWindow::on_pushButton_clicked() { QDateTime time; auto tt = time.currentDateTime(); ui->label1.text(tt.toString()); }Error:
request for member 'text' in '((MainWindow*)this)->MainWindow::ui->Ui::MainWindow::<anonymous>.Ui_MainWindow::label1', which is of pointer type 'QLabel*' (maybe you meant to use '->' ?)
ui->label1.text(tt.toString());
^Why i get error?
thanks -
text()is a getter. you want to use the setter:setText(). Alsolabel1is a pointer so use->instead of..
currentDateTime()is static, so you don't need to create instance ofQDateTimeto use it:auto tt = QDateTime::currentDateTime(); -
Hi
you can remove
QDateTime time; -
Hi
I write this code but get error :void MainWindow::on_pushButton_clicked() { QDateTime time; auto tt = time.currentDateTime(); ui->label1.text(tt.toString()); }Error:
request for member 'text' in '((MainWindow*)this)->MainWindow::ui->Ui::MainWindow::<anonymous>.Ui_MainWindow::label1', which is of pointer type 'QLabel*' (maybe you meant to use '->' ?)
ui->label1.text(tt.toString());
^Why i get error?
thanksThis post is deleted!