2012-02-28 5 views
0

5 개의 QLineEdit 위젯이 줄 지어 있다면. 사용자가 탐색 할 수있게하는 가장 좋은 방법은 무엇입니까?비활성화 된 QLineEdit 위젯을 탐색하는 방법은 무엇입니까?

 
QLineEdit a (enabled) -> QLineEdit b (enabled) -> QLineEdit c (disabled) -> QLineEdit d (disabled) -> QLineEdit e (enabled) 
+0

매우 명확하지 않습니다. 탭을 사용하여 QLineEdits를 탐색 할 때를 의미합니까? 탭 순서에 따라 처리해야합니다. – Correa

+0

탭이 아닙니다. 화살표 키로 탐색. –

+1

나는 이것을 반대합니다. 운영 체제는 대부분이 기능을 Tab 키와 함께 제공합니다. 이 정보를 추가하면 불필요하게 혼동을 일으킬 수 있습니다. –

답변

1

QKeyEvents과 같은 소리입니다. 구현의

class MyClass : public QWidget 
{ 
    //whatever you want 
    protected: 
    //here, override the virtual function keyPressEvent (from QWidget) 
    void QWidget::keyPressEvent(QKeyEvent* ev) 
    { 
    //check for the key(s) you care about and handle the event if needed 
    //by iterating through lineEditList, asking each QLineEdit* if 
    //the 'enabled' property is true. When you find the appropriate one, 
    //set the cursor to that widget. 
    } 
    QList<QLineEdit*> lineEditList; 
    int currentLineEditIndex; 
}; 

구체적인 내용은 물론, 당신에게 달려있을 것이다 :

가장 단순한 구현은 다음과 같이 될 것이다.

+0

고마워. 이런 종류의 구현을 통해 뭔가를 얻었습니다. –

관련 문제