I want to get date from Date edit
-
Hi and welcome
If you made the GUI with Designer, it will be something like
// as real data variable
QDate = ui->dateEdit->date();
QDate Mydate= ui->dateEdit->date()
// as string
StringQString dateString =dateMydate.toString(); -
Thanks for share
Two question:1-Why you use ui ?
2- i write this code and get error :void MainWindow::on_pushButton_clicked() { QDate = ui->dateEdit->date(); String dateString = date.toString(); }
-
Thanks
i have this error :error: expected unqualified-id before '=' token
QDate = dateEdit->date();
^
error: 'date' was not declared in this scope
QString dateString = date.toString();
^and this is my code:
void MainWindow::on_pushButton_clicked() { QDate = dateEdit->date(); QString dateString = date.toString(); }
-
Your are missing the variable name between
QDate
and=
-
and i get error again:
error: 'dateEdit' was not declared in this scope
QDate test = dateEdit->date();
^error: 'date' was not declared in this scope
QString dateString = date.toString();
^warning: unused variable 'test' [-Wunused-variable]
QDate test = dateEdit->date();
^ -
Sorry was not ok sample :)
QDate myDate= ui->dateEdit->date(); // this is only vlaid if u visually design the window and placed dateEdit QString dateString = myDate.toString();
-
You named your QDate variable
test
and then you usedate
in the following line hence the error and the warning.As for the
dateEdit
not declared, you don't have any member variable declared nor initalized with that name.Looks like you're new to C++, please take the time to learn the basics.
-
Sorry was not ok sample :)
QDate myDate= ui->dateEdit->date(); // this is only vlaid if u visually design the window and placed dateEdit QString dateString = myDate.toString();
-
You named your QDate variable
test
and then you usedate
in the following line hence the error and the warning.As for the
dateEdit
not declared, you don't have any member variable declared nor initalized with that name.Looks like you're new to C++, please take the time to learn the basics.