1、用QWidgetTable創建一個表格,每個單元格放入一個QLineEdit,如下圖:

2、想要實作焦點在QLineEdit時,同時選中QLineEdit所在行。
3、QLineEdit與QWidgetTable關聯代碼如下:
HZTableItemBtn *iBtn = new HZTableItemBtn(HZTableItemBtn::ItemType_Color, _editType);
iBtn->setParentTable(this);
iBtn->setGeometry(0, 0, 25, 25);
QHBoxLayout *layout = new QHBoxLayout();
QWidget *widget = new QWidget();
layout->addWidget(iBtn);
widget->setLayout(layout);
4、找了很多種方法都實作不了,有沒有大神指導下。
uj5u.com熱心網友回復:
//設定表格為整行選中table->setSelectionBehavior(QAbstractItemView::SelectRows);
引數含義:
AbstractItemView.SelectItems--選中單個單元格
QAbstractItemView.SelectRows--選中一行
QAbstractItemView.SelectColumns--選中一列
uj5u.com熱心網友回復:
百度一搜就出來的東西不要貼上來了。審題轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/78568.html
標籤:Qt
上一篇:解析度適配
