Hi there,
I'm using QPushButton like a checkbox , so is there any event about Checked state changed in QPushButton thanks for your help.
Hi there,
I'm using QPushButton like a checkbox , so is there any event about Checked state changed in QPushButton thanks for your help.
QPushButton::ischecked() function
isChecked() returns checked state of QPushButton. I wanna catch event everytime changed state of qpushbutton like checkboxs stateChanged(int ) event. thanks ...
Hm... was looking through documentation found something called QWidget::changeEvent...
thx Archa4 but it's not for checked stateChanged ...
Did you try the toggle signal?
http://doc.qt.nokia.com/4.7-snapshot...on.html#toggle
Thanks Rhayader , I just override void QAbstractButton::toggled ( bool checked ) [signal] but it doesn't work, btw my buttons in QButtonGroup , but as document said it works in QButtonGroup but doesn't work as i said ...
You don't need to override the signal. It's a signal. Connect it to a Slot.
http://www.qtcentre.org/faq.php?faq=qt_signalslot........... I think this will help you
i need to override for check something then i emit signal. samething actually (;, still doesn't work btw ...
edit : I typed mistakely slot there ! so this is my mistake many people confused then
Last edited by nightroad; 21st March 2011 at 10:05.
You don't emit a slot.
Connect the toggled signal to a slot and then check what you have to check ?
Then include your codes in the another function and call Q_Emit, it will trigger it
Qt Code:
{ Q_OBJECT public: ~HSPushButton(); ... private: ... signals: ... void stateChanged(bool state); protected: virtual void toggled(bool checked); ... }; HSPushButton.cpp void HSPushButton::toggled(bool checked) { emit (stateChanged(checked)); }To copy to clipboard, switch view to plain text mode
so is it wrong ? I don't think so cuz i'm using escapePressed on my buttons with same method ...
I don't get what is your goal with your HSPushButton class. Can you give us more detail ?
Yes, it is wrong. toggled() as already noted is a signal not a slot. You can't have two functions (a signal and a slot) with the same signature.
Guyz anyway thanks for your help , i'm gonna make it with my own way =) . If i use toggled directly i have to check many thing for each buttons own event so that is crapy ... anyway Thanks all ...
I might be wrong but don't you just want to see which button has been clicked in QButtonGroup?
And does not the signal buttonClicked( int id ) work for you? You can use that on the group rather than individual buttons...
I'd rather say your approach makes it crappy. We don't know what you are doing but you're certainly having an incorrect approach. If you tell us what is the ultimate goal you wish to achieve maybe we'll be able to suggest a better solution.
Just please tell us what you want the HSPushButton class to do what QPushButton doesn't already do.
Bookmarks