How to shift the focus of Qt text box to enter downward
This article introduces the "Qt text box enter focus down how to achieve" the relevant knowledge, in the actual case of the operation process, many people will encounter such a dilemma, then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
I. Preface
Because this demo is too simple to use too much text description, in fact, it realizes that after typing in one text box, enter automatically jumps into the next text box and the focus moves downwards. This is very common in many social security systems, medical systems and other systems, because where those systems require a lot of input, the quickest way is to enter and jump into the next input box after typing is completed. In this way, users do not need to click with the mouse to switch the focus of the cursor, in the process of using the computer, the mouse + keyboard cooperation, the efficiency is the highest, such as in the process of writing code, the need to format the messy code, looks like the mood is much better, it is very convenient to use shortcuts directly at this time, instead of using the mouse to select the menu.
2. Widget::Widget (QWidget * parent): QWidget (parent), ui (new Ui::Widget) {ui- > setupUi (this); connect (ui- > lineEdit1, SIGNAL (returnPressed ()), this, SLOT (next ()); connect (ui- > lineEdit2, SIGNAL (returnPressed ()), this, SLOT (next ()); connect (ui- > lineEdit3, SIGNAL (returnPressed ()), this, SLOT (next ();} Widget::~Widget () {delete ui () } void Widget::next () {QLineEdit * lineEdit = (QLineEdit *) sender (); if (lineEdit = = ui- > lineEdit1) {ui- > lineEdit2- > setFocus ();} else if (lineEdit = = ui- > lineEdit2) {ui- > lineEdit3- > setFocus ();} else if (lineEdit = ui- > lineEdit3) {ui- > lineEdit1- > setFocus ()
This is the end of the content of "how to shift the focus of the Qt text box down". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!