What means this error and how can i fix it?
-
Hello,
what means this error and how can i fix it?C:\Users\henri\Documents\Kodi\Kodi\main.cpp:242: Fehler: could not convert 'fullScreen->QPushButton::<anonymous>.QAbstractButton::click()' from 'void' to 'bool' if(fullScreen->click ()) ^
Hallo,
was bedeutet dieser Fehler und wie kann ich ihn beheben?C:\Users\henri\Documents\Kodi\Kodi\main.cpp:242: Fehler: could not convert 'fullScreen->QPushButton::<anonymous>.QAbstractButton::click()' from 'void' to 'bool' if(fullScreen->click ()) ^
Complete Code snippet:
Kompletter Code-Ausschnitt:QPushButton *fullScreen = new QPushButton; fullScreen->setText ("[ ]"); fullScreen->resize (15, 15); if(fullScreen->click ()) container->setMinimumSize(QSize(screenSize.width() / 1, screenSize.height() / 1));
Thanks for help,
danke,Henrik
-
Hi! It's declared as
void QAbstractButton::click()
, so it does not return any value (void) but yourif (something)
requiressomething
to return a value that is of typebool
or that can be implicitely converted tobool
. -
Besides @Wieland explanation why it dont work, i would like to add the following
You can never check for a button being clicked using a function like that.
" if(fullScreen->click ())"You would always need to connect
connect(button, SIGNAL( clicked() ) , this, SLOT( yourslot))
and then in the function yourslot do what you want.Howver, if u have c++11 enabled , you can cheat a little using something
called lambda, which allows to define the slot locally.like this
connect(loadTextFileButton, &QPushButton::clicked, []() { qDebug()<<"clicked"; });
-
Thanks,
when i copy and paste your Code:
connect(fullScreen, &QPushButton::clicked, { qDebug()<<"clicked"; });
I geht this:
error: expected '}'
note: to match this '{'And the ; behind "clicked" is red underlined...
-
@HenrikSt.
hi if you are using mingw compiler, make sure it
has
config+=c++11in the pro file.
This enable c++ 11 and that is needed for this syntax.
-
I have it:
CONFIG += c++11 -
But the error is still there
-
It works,
thanks a lot