mynahz
9th July 2008, 08:18
I am trying to 'blink' pictures by aternating between 2 QLabels. And since I will have to 'blink' many icons, I was think whether I am able to pass in QLabel like this:
void Mainframe::blinkLabel1_2(QLabel* labelOne, QLabel* labelTwo)
{
static bool on = false;
if(on)
{
labelOne->show();
labelTwo->hide();
on = false;
}
else
{
labelTwo->show();
labelOne->hide();
on = true;
}
}
but I face the following errors
src\mainframe.cpp:42: error: no matching function for call to `Mainframe::blinkLabel1_2(QLabel*&, QLabel*&)'
src\mainframe.h:15: note: candidates are: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: In member function `void Mainframe::on_canbus_RevBoolData(bool)':
src\mainframe.cpp:85: error: no matching function for call to `Mainframe::blinkLabel1_2(QLabel*&, QLabel*&)'
src\mainframe.h:15: note: candidates are: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: At global scope:
src\mainframe.cpp:92: error: prototype for `void Mainframe::blinkLabel1_2(QLabel&, QLabel&)' does not match any in class `Mainframe'
src\mainframe.h:15: error: candidate is: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: In member function `void Mainframe::blinkLabel1_2(QLabel&, QLabel&)':
src\mainframe.cpp:97: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:98: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:103: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:104: error: base operand of `->' has non-pointer type `QLabel'
mingw32-make[1]: Leaving directory `C:/HmiProject/imitDemo1'
mingw32-make[1]: *** [build\host\mainframe.o] Error 1
mingw32-make: *** [release] Error 2
I tried changing the statement to
void Mainframe::blinkLabel1_2(QLabel& labelOne, QLabel& labelTwo)
void Mainframe::blinkLabel1_2(QLabel *labelOne, QLabel *labelTwo)
void Mainframe::blinkLabel1_2(QLabel &labelOne, QLabel &labelTwo)
but it still couldn't work.
Appreciate if someone enlightens me on this. :)
void Mainframe::blinkLabel1_2(QLabel* labelOne, QLabel* labelTwo)
{
static bool on = false;
if(on)
{
labelOne->show();
labelTwo->hide();
on = false;
}
else
{
labelTwo->show();
labelOne->hide();
on = true;
}
}
but I face the following errors
src\mainframe.cpp:42: error: no matching function for call to `Mainframe::blinkLabel1_2(QLabel*&, QLabel*&)'
src\mainframe.h:15: note: candidates are: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: In member function `void Mainframe::on_canbus_RevBoolData(bool)':
src\mainframe.cpp:85: error: no matching function for call to `Mainframe::blinkLabel1_2(QLabel*&, QLabel*&)'
src\mainframe.h:15: note: candidates are: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: At global scope:
src\mainframe.cpp:92: error: prototype for `void Mainframe::blinkLabel1_2(QLabel&, QLabel&)' does not match any in class `Mainframe'
src\mainframe.h:15: error: candidate is: void Mainframe::blinkLabel1_2(QLabel, QLabel)
src\mainframe.cpp: In member function `void Mainframe::blinkLabel1_2(QLabel&, QLabel&)':
src\mainframe.cpp:97: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:98: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:103: error: base operand of `->' has non-pointer type `QLabel'
src\mainframe.cpp:104: error: base operand of `->' has non-pointer type `QLabel'
mingw32-make[1]: Leaving directory `C:/HmiProject/imitDemo1'
mingw32-make[1]: *** [build\host\mainframe.o] Error 1
mingw32-make: *** [release] Error 2
I tried changing the statement to
void Mainframe::blinkLabel1_2(QLabel& labelOne, QLabel& labelTwo)
void Mainframe::blinkLabel1_2(QLabel *labelOne, QLabel *labelTwo)
void Mainframe::blinkLabel1_2(QLabel &labelOne, QLabel &labelTwo)
but it still couldn't work.
Appreciate if someone enlightens me on this. :)