公告
财富商城
积分规则
提问
发文
2020-06-11 12:57发布
乱世女痞
Actually I am new to Qt and unable to match up QMouseEvent with QTableview
QMouseEvent
QTableview
please help in solving this issue.
Here is an example of how you can get a table cell's text when clicking on it.
Suppose a QTableView defined in some MyClass class. You need to connect the clicked signal to your own MyClass::onTableClicked() slot, as shown below:
QTableView
MyClass
connect
clicked
MyClass::onTableClicked()
connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTableClicked(const QModelIndex &)));
Slot implementation:
void MyClass::onTableClicked(const QModelIndex &index) { if (index.isValid()) { QString cellText = index.data().toString(); } }
You can use also doubleClicked, pressed or other signals depending on your goal.
doubleClicked
pressed
最多设置5个标签!
Here is an example of how you can get a table cell's text when clicking on it.
Suppose a
QTableView
defined in someMyClass
class. You need toconnect
theclicked
signal to your ownMyClass::onTableClicked()
slot, as shown below:Slot implementation:
You can use also
doubleClicked
,pressed
or other signals depending on your goal.