-
Notifications
You must be signed in to change notification settings - Fork 0
What We Know About QLineEdit
Table of Contents
A line edit or QLineEdit is a more or less rectangular area on a GUI that typically:
- has space for user input and is use for that
- is a single line
It is a lot like a QPushButton, but that widget is normally for clicking, or QLable which is normally for single line text display but not input. If you want to be clever you can sometimes substitute one for the other, but this is usually a bad idea.
Now we will look deeper into the topic of QLineEdits, and talk a bit about how buttons share many features with many other widgets.
After a widget is created we can change may of its characteristics ( and some of these can also be set up in its init, but changing at a later runtime is more general )
These characteristics are part of the widgets state. Some related to appearance. For example:
- size
- font
- colors
Others are related to user actions the widget can detect and act on
- return pressed
- get focus
Different widget may have different appearance and action states, depending on their intended use.
You can find the code at: https://github.com/russ-hensel/pyqt_by_example/blob/main/tabs/basic_widgets/tab_q_line_edit.py but is better viewed in your own IDE.
Interaction to try on this tab:
- enter and edit text -- we capture several events on the first line edit
- poke around -- do not forget to look at the gui
To see and change the state use the mutate/examine button and read the code in the mutate_x methods.
the documentation is in the code. Coverage is not complete, work continues.
You can use the wat-inspect to find out more or dive into the documentation which is all over the web.
Ask A Simulated Intelligence ( AI ) Sites like ChatGPT do a pretty good job on QT. Here is a prompt that we have found useful:
Suppose you are an experienced Python QT developer. I need help with a QT widget, QLineEdit. I would like to modify the widget so that ..( the background color is red )... Can you give me the code that will do that, please include a version that makes the change at create time, and another that makes the modification after the widget is created. Please include error checking code, if applicable.
We are not doing screenshots any more, run the app and get the real thing.
This link, if it works is to a screenshot of the QPushButton tab.
)