Hi I need to do connect below; is there a way? thanks
Qt Code:
vector <QPushButton*> pb; pb.push_back(pushButton0); ................ connect(pb[i], SIGNAL(clicked()), this, SLOT(mySlot(i)));To copy to clipboard, switch view to plain text mode
Hi I need to do connect below; is there a way? thanks
Qt Code:
vector <QPushButton*> pb; pb.push_back(pushButton0); ................ connect(pb[i], SIGNAL(clicked()), this, SLOT(mySlot(i)));To copy to clipboard, switch view to plain text mode
Regards
Use QSignalMapper. You must register your QObject using QSignalMapper::setMapping() and connect it to QSignalMapper::map() slot. Then you have to connect the mapper to mySlot().
mickey (4th July 2006)
Either you will need to subclass QPushButton and reimplement keyEvents and mouseEvents.
Or you will need to have separate slots for each button like this.
Qt Code:
vector <QPushButton*> pb; pb.push_back(pushButton0); pb.push_back(pushButton1); .......................... connect(pushButton0, SIGNAL(clicked()), this, SLOT(butto0Slot())); connect(pushButton1, SIGNAL(clicked()), this, SLOT(butto1Slot()));To copy to clipboard, switch view to plain text mode
Mithin
www.mithin.in
mickey (4th July 2006)
Subclass QPushButton class and define an overloaded clicked signal.
Qt Code:
signals: void clicked(int);To copy to clipboard, switch view to plain text mode
and a private slot
Now in the constructor connect the above two
Qt Code:
connect(this, SIGNAL(clicked()), this, SLOT(reEmitClicked()));To copy to clipboard, switch view to plain text mode
Now in the defination of reEmitClicked(), emit your overloaded clicked signal.
Now use this overloaded clicked signal, instead of the previous one.
Note: Keep i as a member or property of your class which you can pass through th ctor.
mickey (4th July 2006)
Bookmarks