An example
Subclasses of QTextEdit, QLineEdit and QTreeView all share common
properties, signals and methods. I'd like to write an interface for them.
class AbstractEditor(QWidget):
__metaclass__ = ABCMeta
mysignal = pyqtSignal()
@abstractmethod
def load(self, file):
"""Load `file` into self"""
Then, I'd write each subclass, using this interface
class TextEditor(AbstractEditor, QTextEdit):
"""Implementation here"""
Since QTextEdit is already a subclass of QWidget, it's default
implementation would get called twice, no? And if my interface wasn't
derived from QWidget, or QObject for that matter, I wouldn't be allowed to
use pyqtSignal()?
On 26 October 2013 14:25, Marcus Ottosson <[email protected]> wrote:
> This is more of a general programming question, but I figured it applies
> to Qt programming in particular and I keep encountering it without finding
> any nice enough solution.
>
> I usually write an abstract interface for a set of classes and put
> dependencies on the interface rather than their implementations.
>
> When subclassing QWidget however, how can you make an interface for
> subclasses of an already implemented class? Is multiple inheritance a good
> idea in this scenario?
>
> Currently, I'm writing the interface as a subclass of QWidget, is this a
> good way?
>
> Thanks,
> Marcus
>
>
> --
> *Marcus Ottosson*
> [email protected]
>
--
*Marcus Ottosson*
[email protected]
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA1N10y9eowXUAcuc8dG%2By%3DD04GVBN9rzWAhOaxQVKHsw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.