how to make a tablewidget like this?
-

I just want to make an object like this. when i hovered the item which looks like the up one.what should I do ?
using the delegate of the qtablewidgetitem or putting so many parts of the qpushbutton into a widget ? -

I just want to make an object like this. when i hovered the item which looks like the up one.what should I do ?
using the delegate of the qtablewidgetitem or putting so many parts of the qpushbutton into a widget ?@nicker-player said in how to make a tablewidget like this?:
using the delegate
Yes.
And since it's kinda custom view, I'd go for
QTableViewinstead because it provides more flexibility -
so would u just post a little example for me ?
I wrote a lot but failed.such as when hovered on the whole line of the row,the row comes out a white rectangle with the radius corner.
I just thought if its more easier and effective by using the qwidgets instead of using the delegate.would u give me a little more advices? -
so would u just post a little example for me ?
I wrote a lot but failed.such as when hovered on the whole line of the row,the row comes out a white rectangle with the radius corner.
I just thought if its more easier and effective by using the qwidgets instead of using the delegate.would u give me a little more advices?@nicker-player said in how to make a tablewidget like this?:
so would u just post a little example for me ?
"litte example" a.k.a I do it for you? No.
I wrote a lot but failed
Try harder. Post what you've done so far. It's definitely doable.
-
@nicker-player said in how to make a tablewidget like this?:
so would u just post a little example for me ?
"litte example" a.k.a I do it for you? No.
I wrote a lot but failed
Try harder. Post what you've done so far. It's definitely doable.
@Pl45m4 said in how to make a tablewidget like this?:
doable
void HoveredRowItemExtendDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ //paintWordWrap(painter,option,index); if(option.state.testFlag(QStyle::State_Selected) || option.state.testFlag(QStyle::State_MouseOver)){ qDebug()<<"void HoveredRowItemExtendDelegate::paint()-QStyle::State_Selected"; //QTableWidgetItem *hoveredItem = tableWidget->item(index.row(), index.column()); //if(hoveredItem) //{ const int row = index.row(); for(int column = 0; column < tableWidget->columnCount(); column++){ QTableWidgetItem *item = tableWidget->item(row, column); if(item) { QModelIndex index = tableWidget->model()->index(row, column); QStyleOptionViewItem itemOption = option; itemOption.index = index; itemOption.rect = tableWidget->visualItemRect(item); QStyledItemDelegate::paint(painter, itemOption, index); } } QTableWidgetItem *item0 = tableWidget->item(row, 0); if(item0){ QRect rect = tableWidget->visualItemRect(item0); bool value = index.data(Qt::CheckStateRole).toBool(); QStyleOptionButton checkBoxOption; QRect checkBoxRect = QApplication::style()->subElementRect(QStyle::SE_CheckBoxIndicator, &checkBoxOption); checkBoxOption.rect = rect;// option.rect; checkBoxOption.rect.setLeft(rect.left() + (rect.width() - checkBoxRect.width()) / 2); checkBoxOption.rect.setTop(rect.top() + (rect.height() - checkBoxRect.height()) / 2); checkBoxOption.state = value ? QStyle::State_On :QStyle::State_Off; checkBoxOption.state |= QStyle::State_Enabled; //auto pStyle = option.widget ? option.widget->style() : QApplication::style(); QCheckBox checkBox; //checkBox.setStyleSheet(m_strStyleSheet); checkBox.style()->drawControl(QStyle::CE_CheckBox, &checkBoxOption, painter, &checkBox); //pStyle->drawPrimitive(QStyle::PE_IndicatorCheckBox, &checkBoxOption, painter,&checkBox); } } //} else{ //m_CheckBox->hide(); return QStyledItemDelegate::paint(painter, option, index); } }by the way .which one should i choose .the qlistview or qtableview.
-
Doing this in QWidgets looks like a pain in the ass. It would be pretty easy to do in Qt Quick.