Hi everyone,
I'm new to this forum as to C++ and now Qt. Currently I'm studying this tutorial http://doc.qt.nokia.com/4.4/tutorials-tutorial-t8.html . I hope that some of you are familiar with it?
CODE IN TUTORIAL
~~~~~~~~~~~~~~~~~~~~~~~
In the tutorial they do several connects. I believe those are relevant atm:
- In lcdrange.cpp:
Qt Code:
connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));To copy to clipboard, switch view to plain text mode- In main.cpp
Qt Code:
LCDRange *angle = new LCDRange; connect(angle, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));To copy to clipboard, switch view to plain text mode
So, they connect slider.valueChanged(int) with the slot cannonField.setAngle(int) "via" the signal angle.valueChanged(int).
PROBLEM
~~~~~~~~~~~~~~~~~~~~~~~~~~~
I tried to connect them directly. In main.cpp I added the line
Qt Code:
connect(angle->slider, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));To copy to clipboard, switch view to plain text mode
(I also turned the QSlider * slider public in lcdrange.h)
But then the build problem occurs "cannot convert parameter 1 from 'QSlider *' to 'const QObject *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast". I don't really understand the problem. In my view, they were connected already before, just indirect.
I would be grateful if anybody could explain it to me, thanks!
Bookmarks