简体   繁体   中英

'expression cannot be used as a function' in qt-signals / slot

this is my first entry here and i hope, i will make a well-formed, usefull question.

I do programming with qt since a moment and also did slots and signals with success - the also weird thing is, that it has been worked for a moment, but not anymore - no idea why.

I've done some searches on that error and it seems to be most-often cause of variables and functions with the same name (and on the error-part it will try the var as function). This is checked too but should not be the case.

It's a in-itself-closed qwidget and i just release my lines:

http://pastebin.com/TXXY1cT4

so the problems are the lines in settingwidget.cpp (downer on the paste):

connect(terminalCompleter, SIGNAL(textChanged()), this,SLOT(onNrOfLeds22()));
connect(this->nrOfLeds, SIGNAL(valueChanged(int)), this,SLOT(onNrOfLeds22()));

They seems to be correct compared to my other connectors. A special thing is the class ledSetting in header, but its only used in this class and those connectors make no problems.

Thanks for any help in advance!

Your class has a QPushButton* named connect which hides the connect() function.

Hence the expression not being used as a function, because it is not a function !

Either rename the variable, or if not possible, you can call QObject::connect() explicitely to force the compiler to use the base class' version of connect() .

In addition, you can use (from Qt5 on) Qt's new connect syntax which lets the compiler do the type check for you. It uses function pointers instead of the SIGNAL() and SLOT() macros

QObject::connect( terminalCompleter, &QPlainTextEdit::textChanged, this, &settingWidget::onNrOfLeds22 );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM