2012-02-28 2 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

ありがとう。この種の実装で何かが起こった。 –

関連する問題