[PyQt] Equivalent of Q_PROPERTY's MEMBER for pyqtProperty?
elvstone at gmail.com
Sun Nov 11 14:02:02 GMT 2018
Den sön 11 nov. 2018 kl 14:38 skrev Kyle Altendorf <sda at fstab.net>:
> As I remember it's a mess but that sounds like my @pyqtify (oh what a bad name...) Decorator for @attr.s classes. I use it to create signals so my attrsmodel (for tree views) can be backed by attrs classes.
> Basically for each attrs attribute it creates a property (Python by default, you can specify pyqtProperty instead if you want). The property is used to emit a signal on change. A separate object is created to house the signals and is accessible via epyqlib.utils.qt.pyqtify_signals(). In my case mostly I don't write that much because it's just backend in my model.
> Hopefully someday I'll tidy up my library so it's a bit easier to follow and try out. Sorry.
Ah, thanks for the pointer at least. In my case I was just porting
some C++ code that happened to use MEMBER for one particular property,
so it was no problem to just spell out the setter/getter/signal
> On November 11, 2018 6:14:00 AM EST, Elvis Stansvik <elvstone at gmail.com> wrote:
> >Hi all,
> >E.g. in C++ one can do:
> > Q_PROPERTY(bool showFileDialog MEMBER m_showFileDialog NOTIFY
> > bool m_showFileDialog = false;
> > void showFileDialogChanged();
> >This makes the m_showFileDialog member variable readable and writable
> >without the need of creating READ and WRITE accessor functions, and Qt
> >emits automatically the showFileDialogChanged signal when needed.
> >Is it possible to get this kind of convenience with PyQt?
> >PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt