Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT and custom menu item (QLineEdit)

Tags:

qt

qt4

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):

alt text

like image 644
silent Avatar asked May 25 '10 17:05

silent


People also ask

What is QLineEdit?

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.

How do I get text from line edit in Qt?

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.

How do I read text in QLineEdit?

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 .


1 Answers

You can use a QWidgetAction to contain your QLineEdit. It inherits QAction.

like image 117
Leiaz Avatar answered Oct 05 '22 10:10

Leiaz