tags:

views:

258

answers:

2

PyQt application works fine, but when I close it Python shows this message: "Object::connect: No such signal QObject::dataChanged(QModelIndex,QModelIndex)" What is the cause of this? There isn't dataChanged signal in the program.

EDIT: Almost minimal program which causes error:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *
import ui_DBMainWindow

global Mw, Table
Id, Name, Size = range(3)

class TTable():
    pass

Table = TTable()

class TMainWindow(QMainWindow, ui_DBMainWindow.Ui_MainWindow):

    def __init__(self, parent = None):
        global Table
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.showMaximized()
        self.mapper = QDataWidgetMapper(self)
        self.mapper.setModel(Table.Model)  # if this line is commented out, error disappear

def main():
    global Mw, Table
    QApp = QApplication(sys.argv)
    DB = QSqlDatabase.addDatabase("QSQLITE")
    DB.setDatabaseName("1.db")
    Table.Model = QSqlTableModel()
    Table.Model.setTable("MainTable")
    Table.Model.select()
    Mw = TMainWindow()
    QApp.exec_()

if __name__ == "__main__":
    main()

EDIT 2: 1.db is the database with table MainTable with 3 fields: Id (autoincrement hidden integer key), Name (string), Size (integer). It can be empty, the same error. file ui_DBMainWindow.py:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'C:\blizzard\Projects\PyQt\DB4\DBMainWindow.ui'
#
# Created: Fri Mar 26 22:04:00 2010
#      by: PyQt4 UI code generator 4.4.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 696)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.TableView = QtGui.QTableView(self.centralwidget)
        self.TableView.setGeometry(QtCore.QRect(10, 20, 551, 451))
        self.TableView.setObjectName("TableView")
        self.btAdd = QtGui.QPushButton(self.centralwidget)
        self.btAdd.setGeometry(QtCore.QRect(570, 20, 91, 24))
        self.btAdd.setObjectName("btAdd")
        self.btDel = QtGui.QPushButton(self.centralwidget)
        self.btDel.setGeometry(QtCore.QRect(570, 80, 91, 24))
        self.btDel.setObjectName("btDel")
        self.btEdit = QtGui.QPushButton(self.centralwidget)
        self.btEdit.setGeometry(QtCore.QRect(570, 50, 91, 24))
        self.btEdit.setObjectName("btEdit")
        self.leQueryError = QtGui.QLineEdit(self.centralwidget)
        self.leQueryError.setGeometry(QtCore.QRect(10, 550, 551, 20))
        self.leQueryError.setObjectName("leQueryError")
        self.btQuery = QtGui.QPushButton(self.centralwidget)
        self.btQuery.setGeometry(QtCore.QRect(570, 480, 75, 24))
        self.btQuery.setObjectName("btQuery")
        self.teQuery = QtGui.QTextEdit(self.centralwidget)
        self.teQuery.setGeometry(QtCore.QRect(10, 480, 551, 64))
        self.teQuery.setObjectName("teQuery")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 19))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "База данных", None, QtGui.QApplication.UnicodeUTF8))
        self.btAdd.setText(QtGui.QApplication.translate("MainWindow", "Добавить", None, QtGui.QApplication.UnicodeUTF8))
        self.btDel.setText(QtGui.QApplication.translate("MainWindow", "Удалить", None, QtGui.QApplication.UnicodeUTF8))
        self.btEdit.setText(QtGui.QApplication.translate("MainWindow", "Редактировать", None, QtGui.QApplication.UnicodeUTF8))
        self.btQuery.setText(QtGui.QApplication.translate("MainWindow", "Запрос", None, QtGui.QApplication.UnicodeUTF8))
A: 

One of the methods you are calling tries to connect a slot to a signal named dataChanged on a QObject, which obviously does not emit such a signal. Since there is no dataChanged signal in your program, chances are that some method tries to do it indirectly. Also, since it happens when you are closing your program, I would first look at the code that gets executed when the interpreter shuts down (i.e. destructors and such).

Tamás
+1  A: 

can you provide some code from your application? is there any instances of the following types or their descendants in it? QAbstractItemModel, QAbstractItemView, for example QListView, QTreeView and so one. Try to catch any places, where you connect something to ones, not especially to that signal. You need to look, when these descendant types instanced in your code emit dataChanged, thanks God, Qt is opensource. It seems, that your application thinks, that some object is QAbstractItemModel or QAbstractItemView descendant, whether it is not, and tries to connect a slot to its dataChanged signal.

PS. When you compile some interface by uic, the resulting class inherits from object, not QtGui.QMainWindow or smth. Maybe it is somehow related.

Max