Getting syntax error in tutorial
-
wrote on 13 Jan 2011, 20:48 last edited by
Hi -
I'm trying to run through the tutorials on trolltech, and am currently looking at this one:
"tutorial 5":http://doc.trolltech.com/4.3/tutorial-t5.html
(I'm doing this in eclipse, by the way.)
I'm getting a syntax error on this line:
@ connect(slider, SIGNAL(valueChanged(int)),
lcd, SLOT(display(int)));
@Can someone tell me what's going on here? I don't know enough about connect yet to debug this on my own.
Thanks.
-
wrote on 13 Jan 2011, 21:00 last edited by
And the error is?
-
wrote on 13 Jan 2011, 21:03 last edited by
in my Qt Creator everythink from this tutorial works, and i don't see any mistakes in code.
-
wrote on 13 Jan 2011, 22:00 last edited by
The "Signals & Slots":http://doc.trolltech.com/stable/signalsandslots.html has some good explanations.
EDIT:
The tutorial you linked to is quit outdated. It's from version 4.3, current is 4.7. You can find the recent tutorials "here":http://doc.trolltech.com/stable/tutorials.html. -
wrote on 13 Jan 2011, 23:12 last edited by
Volker: thanks for the link. I'd like to finish these up, though, since I'm halfway through.
Peppe: I don't get anything more specific than simply "syntax error"...I did try building it, and it builds without an error or warning, so now I'm really confused. I wonder if there's some invisible character that I accidentally copied and pasted in with the code. Not sure what to do at this point; maybe this is more an eclipse problem than a Qt problem.
-
wrote on 14 Jan 2011, 06:43 last edited by
Do you get an error when building? When I used eclipse ages ago it did not understand the signal/slot mechanism in Qt:-( Better use Qt Creator...
-
wrote on 14 Jan 2011, 16:37 last edited by
Hi, Tobias -
No, no error when building. I probably should ignore it, but I like to understand stuff like this. I would use Qt Creator, but I'm going to need an IDE eventually, so I'd like to try to get this resolved.
-
wrote on 14 Jan 2011, 16:39 last edited by
Then it's likely to be eclipse not recognizing Qt keywords.
-
wrote on 14 Jan 2011, 16:41 last edited by
[quote author="mzimmers" date="1295023042"]...but I'm going to need an IDE eventually...[/quote]
"Qt Creator":http://qt.nokia.com/products/developer-tools/ is an IDE, a multi-platform, fast, very nice IDE -
wrote on 14 Jan 2011, 18:13 last edited by
[quote author="Zlatomir" date="1295023281"]"Qt Creator":http://qt.nokia.com/products/developer-tools/ is an IDE, a multi-platform, fast, very nice IDE
[/quote]OK...I guess I should take a closer look at it.
Do you know of any tutorials that focus on learning the tools, rather than learning Qt per se? The tutorials I'm doing now are interesting, but I don't think I'm learning much about the development tools.
Thanks.
-
wrote on 14 Jan 2011, 18:58 last edited by
I am not aware of any specific tutorials, but there was a presentation about "Getting the most out of Qt Creator" at the devdays. The video is available "here":http://qt.nokia.com/developer/learning/online/talks/developerdays2010/tech-talks/getting-the-most-out-of-qt-creator.
-
wrote on 14 Jan 2011, 19:02 last edited by
OK, thanks...I also found this after I asked the question:
http://doc.qt.nokia.com/qtcreator-2.0.1/
I'm just getting started in it, but it looks pretty good.
I'll play with this for awhile and see how it works for me.
Thanks again for the help.
-
wrote on 14 Jan 2011, 19:06 last edited by
That documentation is also available inside Qt Creator (In "Help" mode, Ctrl-6). I'd recommend upgrading to Qt Creator 2.1 RC. It is very close to what will get released as 2.1 soonish (we hope) and has quite some improvements:-)
-
wrote on 14 Jan 2011, 19:15 last edited by
[quote author="Tobias Hunger" date="1295031962"]That documentation is also available inside Qt Creator (In "Help" mode, Ctrl-6).[/quote]
Yeah, I know, but...it's kind of hard to switch back and forth between the in-application documentation, and the views that I actually use to do the work. It's easier just to read the documentation from a browser. (I have two displays.)
[quote]I'd recommend upgrading to Qt Creator 2.1 RC. It is very close to what will get released as 2.1 soonish (we hope) and has quite some improvements:-)[/quote]
I'm willing to give that a try; where do I find it? Is it available for Mac?
-
wrote on 14 Jan 2011, 20:29 last edited by
Qt Creator 2.1 RC is available "here":http://qt.nokia.com/developer/qt-qtcreator-prerelease/.
-
wrote on 15 Jan 2011, 04:26 last edited by
OK...it seems to be running. I'll play with it some more tomorrow.
In the meantime (and I know the answer is right in front of me), how do I get to the window in step 2 of this page?
"creator example":http://doc.qt.nokia.com/qtcreator-2.0.1/creator-build-example-application.html
-
wrote on 15 Jan 2011, 07:49 last edited by
Open any .pro-file that you have not opened in Creator before.
-
wrote on 17 Jan 2011, 01:57 last edited by
OK, but...what about when creating a brand-new project? The tutorial shows a dialog box for selecting tagets that I can't find. I'm sure it's right under my nose, but...I can't figure out how to get to it.
-
wrote on 17 Jan 2011, 02:00 last edited by
[quote author="mzimmers" date="1294951724"]Hi -
I'm getting a syntax error on this line:
@ connect(slider, SIGNAL(valueChanged(int)),
lcd, SLOT(display(int)));
@
[/quote]I did a little playing around with this, and discovered that removing the of occurances of (int) in the code, and replacing them with something like (0) eliminated the error. Not sure what this means, but...it does seem odd that eclipse would give me an error on this.
-
wrote on 17 Jan 2011, 10:03 last edited by
SIGNAL and SLOT are supposed to contain a signature of a method, so it must contain "int", not 0. Your changed code will not work: At runtime it will fail to connect the signal to the slot.
1/25