[PySide] combining two default widgets
a.richi at bluewin.ch
Sun Oct 20 11:13:42 CEST 2013
Tried your code and it works fine (BTW: if you want to check us some
code, it would be nice if the code is executable and shows a working
example of your widget, otherwise all of us first have to write some
lines of code to show your widget and chances are smaller that anybody
tries it at all...).
There are no general guidelines about multiple inheritance, it's an
endless discussion whether it's a good or a bad thing... I can just give
you my guidelines, others will contradict:-)
- in your case, it's definitively the wrong choice (see below)
- use it wisely and rarely (I've only used it in two cases in my entire
- learn about the internals (e.g. how conflicting function names are
Reason, why it's definitively not a good idea here: You wanted a mix of
both looks and feels. The visual appearance should be somewhere between
a combobox and a progress bar. So you want e.g. the paintEvent() of both
classes to be executed. But since QComboBox is first in the inheritance
order, only QComboBox.paintEvent() would be executed, your widget would
never look like a progress bar. And this is just one example of
Implementing your own widget starting from QComboBox or from
QProgressBar as you did now is the way I would choose.
Am 20.10.2013 07:37, schrieb Frank Rueter | OHUfx:
> Hi all,
> I have written a custom comboBox which renders like a progress bar.
> Depending on which item is chosen, the progress bar is updated accordingly:
> Initially I thought I'd be cheeky and try to inherit both QComboBox and
> QProgessBar (in that order) to see if this is the easiest way to do
> this, but the app crashed as soon as I used self.setItems() in the
> I don't have a lot of experience with inheriting more than one object,
> so thought I'd ask you guys for general guide lines (if there are any).
> I'd imagine it's only safe to do if you know that none of the respective
> attributes cause conflicts?!
> Also, is the above code an ok way of doing this? I would just like to
> know if this is how the pros would do it and avoid bad habits.
> PySide mailing list
> PySide at qt-project.org
More information about the PySide