[Beginner Question] Cannot get this Code to run
Hello Community, i play a little bit with signals/slots (hte manual way) but my code does not work.
class Demo : public QObject
int main(int argc, char* argv)
//Create a new QPushButton QPushButton * button = new QPushButton("Hello Wolrd!"); button->show();
//Construct my Class
Demo *dapp = new Demo();
//Here i try to connect that on pressing the Button the Demo->showMessage Member will be displayed
What did i wrong in the connect Member?
Thanks for Help!
You must connect to the Demo object, not the QApplication object:
You should have got a warning message that the connect failed on application startup.
No problem - you're welcome.
The "&button" should really just be "button". button already is a pointer, no need to turn it into a pointer to a pointer...
Sorry, but you are a little bit inconsecutive (see the "star" place):
QPushButton * button
This can confuse other developers.
When you declare (or define) a pointer, bind the "star" to the type, and when you dereference a pointer, bind the "star" to the variable name.
Yea, thank you i will declare it better in my next little failure programms :)