Qt / C ++ QTableWidget:当头被双击时做某事 [英] Qt/C++ QTableWidget: Doing something when a header is doubleclicked
问题描述
我有一个QTableWidget在我的形式,我想做一些事情,当用户双击行或列的标题。我使用以下connect语句:
I have a QTableWidget in my form and I want to do something when a user doubleclicks on the header of a row or column. I am using the following connect statement:
connect(ui->tblResults->horizontalHeader(),SIGNAL(doubleClicked(QModelIndex)),this,SLOT(tableDoubleClicked(QModelIndex)));
其中此
是窗口类和ui - > tblResults是窗体窗体上的QTableWidget。当我尝试双击标题,没有任何反应。我连接的插槽是:
Where this
is the window class and ui->tblResults is the QTableWidget on the window's form. When I try doubleclicking the header, nothing happens. The slot I'm connecting to is:
void wndSearch::tableDoubleClicked(QModelIndex tmp){
QMessageBox::information(0,"DERP!","TEST");
}
很简单,只是测试看看插槽是否被调用。我从来没有收到这个消息框。我没有得到任何运行时错误connect()调用。
Very simple, just testing to see if the slot gets called. I never receive this messagebox. I am not getting any runtime error on the connect() call.
我使用错误的信号吗?还有别的错误吗?如果您需要更多信息,请告诉我们,感谢您的帮助!
Am I using the wrong signal? Is something else wrong? Please let me know if you need anymore information, and thanks for the help!
freenode的#qt中的某人帮助了我。 SIGNAL我在寻找是sectionDoubleClicked(int)
[edit] Someone in #qt on freenode helped me out. SIGNAL I was looking for was sectionDoubleClicked(int)
推荐答案
http://doc.qt.nokia.com/latest/qheaderview.html#sectionDoubleClicked
您可以通过 QTableWidget :: horizontalHeader()
或 QTableWidget获取
。 QHeaderView
:: verticalHeader()
You can get the QHeaderView
via QTableWidget::horizontalHeader()
or QTableWidget::verticalHeader()
.
这篇关于Qt / C ++ QTableWidget:当头被双击时做某事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!