QT QTableView 双击获取某行的所有信息

(1) 设置双击事件的代码

    ListViewUp->setSelectionBehavior(QAbstractItemView::SelectRows);
    bool   value = connect(ListViewUp, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotRowDoubleClicked(const QModelIndex &)));

(2)获取详细信息
    void homePage::slotRowDoubleClicked(const QModelIndex &index)
    {
        int row = ListViewUp->currentIndex().row();

        for(i = 0; i < 4; i++)
        {
            QModelIndex index = modelViewOneUp->index(row,i);
            QString name = modelViewOneUp->data(index).toString();
            qDebug()<<name;

        }

    }

猜你喜欢

转载自blog.csdn.net/qq_14874791/article/details/109015014