python - PySide: QMetaObject.connectSlotsByName emits warnings "No matching signal..." but still works..? -


in qt designer, created qdialog window , used pysideuic compile base class contains setupui method initialising gui elements , extend implement functionality, so:

class mydialog(qtgui.qdialog, ui_file.ui_main_dialog):     def __init__(self, parent=none):         qtgui.qdialog.__init__(self, parent)         ui_file.ui_main_dialog.__init__(self)         self.setupui(self) 

this setupui method has calls qtcore.qobject.connect signal-slot connections created in qt designer, added new slots gui. these slots non-existent in base class generated pysideuic , added them mydialog class, e.g.

    def on_list_selection_changed(self):         self.run_btn.setenabled(len(self.modules_list.selectedindexes()) > 0) 

for example, slot called on_list_selection_changed() (with empty parameter list) in qt designer.

on initialisation, mydialog.__init__ calls ui_main_dialog.setupui, calls qtcore.qmetaobject.connectslotsbyname (the latter 2 mydialog instance's self being created). emits following line on sys.stderr:

qmetaobject::connectslotsbyname: no matching signal on_list_selection_changed() 

still, signal behaves correctly , slot called when connected modules_list.itemselectionchanged() (modules_list qlistwidget).

so here question: why receive warning? can doesn't appear, given seems irrelevant?


edit: since didn't receive answers in last 5 months, thought give complete example make reproducing problem easier.

this example differs question above in uses qlineedit instance. here code:

import sys pyside import qtcore, qtgui  class ui_dialog(object):     def setupui(self, dialog):         dialog.setobjectname("dialog")         self.lineedit = qtgui.qlineedit(dialog)         self.lineedit.setobjectname("lineedit")         qtcore.qobject.connect(self.lineedit, qtcore.signal("textchanged(qstring)"), dialog.on_lineedit_changed)         qtcore.qmetaobject.connectslotsbyname(dialog)  class mainwindow(qtgui.qmainwindow, ui_dialog):     def __init__(self, parent=none):         qtgui.qmainwindow.__init__(self, parent)         ui_dialog.__init__(self)         ui_dialog.setupui(self, self)     @qtcore.slot(unicode) # signal no arguments     def on_lineedit_changed(self, text):         print 'changed to', text  if __name__ == '__main__':     app = qtgui.qapplication(sys.argv)     mw = mainwindow()     mw.show()     sys.exit(app.exec_()) 

note code ui_dialog class generated pysideuic qt designer's .ui file, shortened bit better highlight problem.

i have same issue in c++. connectslotsbyname hard-coded output message if finds slot can't connect automatically, though don't need automatic connection because you've done explicitly yourself. can use qinstallmsghandler suppress warnings in general or write messages somewhere better don't think there's way tell connectslotsbyname don't care case in particular.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -