我创建了一个 QStyledItemDelegate 类,在该类中我想让一些项目可检查,一些项目带有两个小部件。但它不能正常工作。我错过了什么?这是它的样子:
见第 1 行,看起来两个小部件在那里,但它们并没有真正显示出来。我需要一些帮助才能使项目可检查(这与添加复选框不同?)。谢谢你。
这是我的 QStyledItemDelegate 类:
//! [0]
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
}
//! [0]
//! [1]
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.row()==1) {
QLineEdit* lineBox;
QCheckBox* checkBox;
QWidget *panel;
panel = new QWidget(parent);
QHBoxLayout *layout = new QHBoxLayout;
lineBox = new QLineEdit( );
lineBox->setText("abc");
checkBox = new QCheckBox( );
layout->addWidget(checkBox);
layout->addWidget(lineBox);
panel->setLayout(layout);
return panel;
}else if (index.row()==2) {
// need to make this check-able item?
}else{
QLineEdit *editor …Run Code Online (Sandbox Code Playgroud) 我需要在用户单击按钮后执行操作,这可能需要一些时间。如何显示“忙碌”或“请稍候”图标/消息(如旋转圆圈等)并防止用户在此期间再次单击该按钮(或其他一些按钮)?谢谢。