QToolTip::show problem
-
hi please check this and help me . tnx alot
my qt library is 4.8.1 vs2008 sp1@
#ifndef FORM_H
#define FORM_H#include <QtGui>
class form : public QWidget
{
Q_OBJECT
public:
explicit form(QWidget *parent = 0);private slots:
void onbtnclick();private:
QLineEdit *l;
QPushButton *b;
};#endif // FORM_H
@@
#include "form.h"form::form(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *lay = new QVBoxLayout( this );l = new QLineEdit; b = new QPushButton; lay->addWidget( l ); lay->addWidget( b ); connect(b, SIGNAL(clicked()), this, SLOT(onbtnclick()));
}
void form::onbtnclick()
{
QToolTip::showText(l->pos(), "sometext", l);
}
@@
#include "form.h"int main(int argc, char **argv)
{
QApplication app( argc, argv );form f; f.show(); return app.exec();
}
@i want tooltip display for lineedit but display in other region and out of my widget !!!!
-
Try:
@1->setToolTip("sometext");@instead of your line in "onbtnclick()"
-
i know but i want this instead of setToolTip ! please guide me with QToolTip::show static function
-
Okay sorry, I didn't understand your initial question. Just to clarify, you want to display a tooltip - and define its position. The first argument in showText() defines the point of interest, not the point of display, so i don't think you can achieve your goal using that function. Have you thought of creating a label widget to look just like a tooltip and using a hover event to trigger it?
-
ok know please help me how can i do this ? in my example please help me.
-
Read the "QHoverEvent Doc":http://doc.qt.nokia.com/4.7-snapshot/qhoverevent.html and once you set up your hover signal, create a slot that shows your custom tooltip.
-
i read your link and i really tnx you but i cant understand how to use of hover ! if you can please show me with a very very simple example . very very tnx
-
According to "QToolTip::showText":http://qt-project.org/doc/qt-4.8/qtooltip.html#showText docs, ...
bq. Shows text as a tool tip, with the global position pos as the point of interest
So you need to map widget coordinates to global : "QWidget::mapToGlobal":http://qt-project.org/doc/qt-4.8/qwidget.html#mapToGlobal