I created a standard buttonBox from QtDesigner with Ok, Cancel, Reset.
I successfully connected the Ok and Cancel buttons using,
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
even defining my own accept function.
So how would I connect the reset button to say function "foo()". I really have no idea. I read the docs about assigning roles and stuff, and its confusing.
Thanks in advance.
In python .-
self.buttonBox.button(QtGui.QDialogButtonBox.Reset).clicked.connect(foo)
I don't know python, but how you could do this in C++ is something like this:
QPushButton *resetButton = ui->buttonBox->button(QDialogButtonBox::Reset);
connect(resetButton, signal(clicked()), this, SLOT(myResetFunc()));
This of course requires that you set the role for your reset button to QDialogButtonBox::Reset
Using the button function you can get your reset button and connect it to your slot. This is the list of roles your buttons can have. I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With