[Solved] How do I use Creator with C++?
I've recently started using Qt Creator 2.2.1. I've had no problem going through the first few modules in Qt Quick for Designers, but everything's in QML.
What I'm trying to do now is develop something, anything in C++. I've seen the short Hello World program in several places and have tried to get it to work. If you aren't familiar, here's the program:
int main(int argc, char argv)
QApplication app(argc, argv);
QPushButton button = new QPushButton("Hello There");
This is as simple as it gets, but I can't get it to run in Creator. I've created a new project using Qt Quick Project -> Qt Quick Application. I get an error on the #include statement.
What is the error you get? We don't have a christal ball you know ;)
At a minimum, in the the example you gave, you'll want to add
[quote author="Endless" date="1312912624"]I've created a new project using Qt Quick Project -> Qt Quick Application. I get an error on the #include statement.[/quote]
There is your error, use Qt Widget Project -> Qt Gui Application
Apparently the additional include statement got me what I needed. Thanks so much for the help. One last question, though: I thought when I clicked on the button, it would terminate the application. I can click it as many times as I want, but the app doesn't end.
You don't have any action tied to the button's clicked() signal.
After you create the button, you'll want to add
QObject::connect(button, SIGNAL(clicked(), &app, SLOT(quit()));
to connect button's clicked() signal to the application's quit() slot.
Yes, mlong, that did it. Thanks for the help.
Glad to help! Be sure to edit the thread title and add [Solved] to the beginning! Thanks!