gebbissimo
31st August 2012, 19:13
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:
connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
In main.cpp
LCDRange *angle = new LCDRange;
connect(angle, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));
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
connect(angle->slider, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));
(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!
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:
connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
In main.cpp
LCDRange *angle = new LCDRange;
connect(angle, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));
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
connect(angle->slider, SIGNAL(valueChanged(int)), cannonField, SLOT(setAngle(int)));
(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!