[solved] error with connecting functions to button
Myself trying to write a program in Qt connecting a function to a button in Qt5.
static void insert()
qDebug() << "pressed";
int main(int argc,char *argv)
QPushButton *button=new QPushButton("button");
But I am getting errors like
main.cc:23:39: error: within this context
main.cc:23:55: error: invalid use of void expression
make: *** [main.o] Error 1
[code tags and solved, added, koahnig]
You supplied the QObject::connect function with a void function outcome as a third parameter while it was expecting a function object or a function pointer. Try this instead:
@ QObject::connect(button, &QPushButton::clicked, insert);@
Still, with this code you won't see much; you should implement an application window and put this button inside.
It worked ..Thank u for the reply..
Please checkout the ForumHelp for advice on postings. "Code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 do improve the layout of your posting significantly. I have added them for you this time.