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?
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?
Yes you forgot set main widget for your app..look in next code
Qt Code:
#include <QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { MainWindow *MainForm = new MainWindow; app.setMainWidget(MainForm); MainForm->show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
a life without programming is like an empty bottle![]()
You can't add parameter values to signal-slot connections.Originally Posted by Morea
In the constructor of MainWindow:
change:
Qt Code:
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:
Qt Code:
#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)));To copy to clipboard, switch view to plain text mode
Strange, I've managed without that before.Originally Posted by zlatko
I will try that, thank you.Originally Posted by jpn
Are there any other way of getting the same functionality? I mean, a different design, or you will most likely need to use the mapper unless you wish to create 10 different slots, one for each digit?
The signal mapper is intended for situations like yours.Originally Posted by Morea
Yes, one approach could be to create a bunch of slots, a different slot for each digit.. Not very handy, right![]()
Isn't application's main widget obsolete in Qt 4..Originally Posted by zlatko
One could use a QButtonGroup instead of a signal mapper too. It would be more natural than using QSignalMapper.
Bookmarks