我有一个 QListView,我从中获得一个 QAbstractItemModel 与 list->model();
在此之后,我想将 dataChanged 信号连接到我的自定义 QObject:
if( QObject::connect(model, SIGNAL(dataChanged (const QModelIndex , const QModelIndex ) ),
customObject_,SLOT(onText(const QModelIndex , const QModelIndex )) ) )
cout << "SIGNAL SLOT connection successful" << endl;
else
cout << "SIGNAL SLOT connection ERROR" << endl;
这是我的自定义对象:
class CustomObject : public QObject
{
Q_OBJECT
public:
CustomObject (QObject *parent);
~CustomObject ();
public slots:
void onText(const QModelIndex & topLeft, const QModelIndex & bottomRight );
private:
};
我做错什么了吗?QObject 调用返回 true,我在 onText 函数中有一个 cout,但是当 QListView 更改时没有打印任何内容。