Help with autoconnect
03 May 2021 23:37 #207769
by persei8
Help with autoconnect was created by persei8
I'm sick of editing the signal/slot connections that get broken every time I move a widget. Apparently, QT can auto-connect widget signals to handler slots. What I have is:Then down in the initialized__(self) module:I have tried self, self.w and WIDGETS. Using the latter 2 does not create errors but no connections are made either.
The slots look like this:All slots that I'm trying to autoconnect have been deleted from the designer signal/slot editor.
Any advice on what I'm doing wrong?
Jim
from PyQt5 import QtCore
from qtvcp.qt_makegui import VCPWindow
WIDGETS = VCPWindow()
QtCore.QMetaObject.connectSlotsByName(WIDGETS)
The slots look like this:
@QtCore.pyqtSlot()
def on_object_name_clicked():
etc.
Any advice on what I'm doing wrong?
Jim
Please Log in or Create an account to join the conversation.
04 May 2021 15:23 #207838
by cmorley
Replied by cmorley on topic Help with autoconnect
self (the HandlerClasss) is not a subclass of QObject so connecting by 'slotname' won't work.
self.w is a subclass of QObject but doesn't have the handler functions in it in a way that 'slotname' can find it it seems.
I don't quite understand how designer connects to the handler file functions at the moment.
Don't use this in the handler file- it's exactly the same as self.w
Chris
self.w is a subclass of QObject but doesn't have the handler functions in it in a way that 'slotname' can find it it seems.
I don't quite understand how designer connects to the handler file functions at the moment.
from qtvcp.qt_makegui import VCPWindow
WIDGETS = VCPWindow()
Don't use this in the handler file- it's exactly the same as self.w
Chris
Please Log in or Create an account to join the conversation.
04 May 2021 23:25 #207900
by persei8
Replied by persei8 on topic Help with autoconnect
OK thanks. I find it just as easy to create a new class in another module that explicitly makes all the connections. It works good and makes it way easier to manage especially when doing extensive changes to the designer file. I may integrate it with the handler later.
Jim
Jim
Please Log in or Create an account to join the conversation.
Moderators: cmorley
Time to create page: 0.061 seconds