Solved I want to get date from Date edit
-
Hi and welcome to devnet,
- Like @mrjj wrote, that's valid if you used a Designer based form.
- String is not a Qt class, the name is QString.
By the way, what exact error are you getting ?
-
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.
-
Thanks for share
I solve my problem -
@SGaist
Thank you
Solve -
@Armin
Super Please select Topic Tools button and mark as Question and then select Solved. -
@mrjj
Thanks
I did it . correct?
mrjj: yes :)