2010-06-01 48 views
-1

我在QT這個代碼和所有我想趕上點擊事件時,在樹視圖行的一個部分一個點擊沒有成功QT點擊信號dosnt工作在QStandardItemModel與樹視圖

這裏是我的代碼:

(parant is the qMmainwindow) 
m_model = new QStandardItemModel(0, 5, parent); 
// then later in the code i have 
proxyModel = new QSortFilterProxyModel; 
proxyModel->setDynamicSortFilter(true); 
setSourceModel(createMailModel(parent)); 
ui.treeView->setModel(proxyModel); 
ui.treeView->setSortingEnabled(true); 
ui.treeView->sortByColumn(4, Qt::DescendingOrder); 
// and my signal/slot looks like this but its not working 
//and im not getting eny clicked event fired 
connect(ui.treeView,SIGNAL(Clicked(const QModelIndex&)), 
     this,SLOT(treeViewSelectedRow(const QModelIndex&))); 

還如何調試QT信號/插槽,所以我可以看到一些調試按摩打印 什麼是錯的?

回答

2

小寫字母c表示點擊信號。

connect(ui.treeView,SIGNAL(clicked(const QModelIndex&)), 
    this,SLOT(treeViewSelectedRow(const QModelIndex&))); 
+0

感謝您的回答,您知道第二個問題 – user63898 2010-06-01 08:05:07

+0

的答案對不起,我錯過了。如果你從visual studio或qt creator或類似的東西運行程序,連接錯誤將被髮送到調試窗口。否則,shadow的答案(檢查QObject :: connect的返回值)是我能想到的唯一的其他事情.. – ianmac45 2010-06-01 11:24:10

0

調試信號和槽,檢查連接的connect.the返回類型的返回值的類型爲BOOL,如果返回true,則其連接別的它不是。