Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolTip::show problem
Forum Updated to NodeBB v4.3 + New Features

QToolTip::show problem

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahura_24
    wrote on last edited by
    #1

    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&#40;&#41;;
    

    }
    @

    i want tooltip display for lineedit but display in other region and out of my widget !!!!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Blizzard
      wrote on last edited by
      #2

      Try:
      @1->setToolTip("sometext");@

      instead of your line in "onbtnclick()"

      Software Engineer | Aerospace & Defence

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ahura_24
        wrote on last edited by
        #3

        i know but i want this instead of setToolTip ! please guide me with QToolTip::show static function

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Blizzard
          wrote on last edited by
          #4

          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?

          Software Engineer | Aerospace & Defence

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ahura_24
            wrote on last edited by
            #5

            ok know please help me how can i do this ? in my example please help me.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Blizzard
              wrote on last edited by
              #6

              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.

              Software Engineer | Aerospace & Defence

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ahura_24
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cincirin
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved