How can I use QLineEdit as a menu item in QMenu? Is there any solutions to do this?
Just to do something like this (look at the edit box under the avatar):
The QLineEdit widget is a one-line text editor. A line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop.
You use QLineEdit::setText() to change the text and QLineEdit::text() to read. Your questions are very basic and show a clear lack of studying the documentation and experimenting thing yourself. Qt is one of the better documented frameworks out there and with lots of examples.
As mentioned in the documentation, the text of a QLineEdit can be retrieved with its method text . Note that it's a QString , not a regular string, but that shouldn't be a problem as you format it with your "%s" % text .
You can use a QWidgetAction to contain your QLineEdit. It inherits QAction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With