zoukankan      html  css  js  c++  java
  • 点击 QTableView,触发事件

    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:

    connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTableClicked(const QModelIndex &)));

    注意:QT的connect只写参数类型,不写参数名。

    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.

  • 相关阅读:
    学习笔记::有上下界的网络流
    zoj2314
    bzoj3261
    bzoj 1898
    bzoj4009
    bzoj4033
    bzoj3389
    bzoj2427
    uva 11825
    交换A与B值的四种方法
  • 原文地址:https://www.cnblogs.com/liujx2019/p/10309789.html
Copyright © 2011-2022 走看看