
Originally Posted by
Morea
I have attached the code, the problem is: it doesn't show anything. I can't figure out why. I think I've done it right, but obviously I haven't.
Can you see why I don't get any out put?
You can't add parameter values to signal-slot connections.
In the constructor of MainWindow:
change:
connect(ui.siffra9,SIGNAL(clicked()),&C,SLOT(addToCurrentNumber(9)));
[...]
connect(ui.siffra0,SIGNAL(clicked()),&C,SLOT(addToCurrentNumber(0)));
connect(ui.siffra9,SIGNAL(clicked()),&C,SLOT(addToCurrentNumber(9)));
[...]
connect(ui.siffra0,SIGNAL(clicked()),&C,SLOT(addToCurrentNumber(0)));
To copy to clipboard, switch view to plain text mode
to:
#include <QSignalMapper>
connect(ui.siffra9, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui.siffra9, 9);
[...]
connect(ui.siffra0, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui.siffra0, 0);
connect(mapper, SIGNAL(mapped(int)), &C, SLOT(addToCurrentNumber(int)));
#include <QSignalMapper>
QSignalMapper* mapper = new QSignalMapper(this);
connect(ui.siffra9, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui.siffra9, 9);
[...]
connect(ui.siffra0, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui.siffra0, 0);
connect(mapper, SIGNAL(mapped(int)), &C, SLOT(addToCurrentNumber(int)));
To copy to clipboard, switch view to plain text mode
Bookmarks