Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to enter a character to qlineEdits from pushButtons depending on the selected lineEdit



  • I am using QT creator to make a UI. UI consists of two or more lineEdits and ten pushButtons to input 0-9 numberic characters to lineEdits. How can I enter 0-9 number strings in both lineEdits one by one.

    If I press pushButton with label '5' and cursor is on lineEdit (say lineEdit 1) it should append '5' in lineEdit 1 or if lineEdit 2 is selected it should append '5' in lineEdit 2 and any number of lineEdits respectively with 0-9 numeric pushButtons also.


  • Lifetime Qt Champion

    Hi
    look at this sample
    http://www.java2s.com/Code/Cpp/Qt/Calculatorwithpushbuttons.htm
    Shows how to hook up buttons etc. (its numeric keypad)

    you can change it to use
    QApplication::focusWidget () const

    to input to whatever LineEdit that is selected.


Log in to reply