如何将QLineEdit用作编辑器时如何调整大小?

时间:2012-01-11 15:17:02

标签: windows qt

QWidget* EditDelegate::createEditor(
  QWidget* parent,
  const QStyleOptionViewItem& option,
  const QModelIndex& index) const
{
  QLineEdit* editor = NULL;
  if(index.isValid())
  {
    editor->resize(50,1000);  //this can not work in win7
  }
  return editor;
}

EditDelegate是QItemDelegate的子类 你们怎么看待这个问题?

1 个答案:

答案 0 :(得分:0)

声明QLineEdit指针后,需要创建类的实例

if(index->isValid()) {
  editor = new QLineEdit();
  editor->resize(50, 1000);
}