On a dialog I have a QLineEdit and a button. I want to enable a tool tip for the QLineEdit(in it or under it) when I press the button. Please give me a code snippet.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is a simple example:
As you can see, there is no easy way to just enable the tool tip of some widget. You have to provide global coordinates to
QToolTip::showText.Another way to do this is to create a
QHelpEventyourself and post this event usingQCoreApplication::postEvent. This way, you can specify the text to be shown in your widget usingQWidget::setToolTip. You still have to provide global coordinates, though.I am really interested in why you want to do this since tool tips are intended to be shown only when you hover your mouse or when you ask for the “What’s this” information. It looks like bad design to use it for something else. If you want to give a message to the user, why don’t you use
QMessageBox?