2012-01-11 2 views
0
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의 하위 클래스입니다.
당신은이 질문에 대해 어떻게 생각합니까?QLineEdit이 편집기로 사용될 때 어떻게 크기를 조정할 수 있습니까?

+0

왜 당신은 크기를 조정하려고? 일반적으로 Qt는 사용중인 뷰에 따라 모든 것을 처리 할 것입니다. – Chris

+0

왜 1000 픽셀 높이로 편집기를 설정하려고하는지 묻습니다. – Karlson

+0

그냥 내 실수 –

답변

0

당신이 QLineEdit 포인터 클래스의 인스턴스를 만들 필요가 선언 후

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

모두들 감사드립니다! 나는이 질문을 해결했다. QAbstractItemView에는 시스템 함수 "indexWidget (...)"이 있습니다. 하하, 다음과 같이 할 수 있다는 것을 알았습니다 : QWidget * editor = indexWidget (m_indexCurrent); QLineEdit * eee = qobject_cast (편집자); eee-> "당신이 좋아하는 것을 설정하십시오" –

관련 문제