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. "Blinking" tooltip
Forum Updated to NodeBB v4.3 + New Features

"Blinking" tooltip

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • FolcoF Offline
    FolcoF Offline
    Folco
    wrote on last edited by
    #1

    Hi,

    I'm using Qt5.7 32 bits bundled with MinGW, Win10 x64.

    I'm using a QLineEdit in a QWizardPage.
    I want the user to give a valid path.
    Here is a screenshot to visualize : http://www.mirari.fr/GRJw.png

    Here is the relevant part of the header:

    class PageParkLocation : public QWizardPage
    {
        public:
            PageParkLocation(QWidget* parent, QString title);
    
        private:
            QLineEdit* editLocation;
            bool isComplete() const override;
    

    As said in the QWizardPage documentation, I have overriden the isComplete method to ensure that the path is valid before the user may continue.

    Here is my code:

    bool PageParkLocation::isComplete() const
    {
        // Don't use the QDir(QString str) constructor, because the path is set to QDir::homePath() if str is empty
        QDir dir;
        dir.setPath(this->editLocation->text());
    
        // Complete is the return value, true if the user may continue, else false
        bool complete = dir.exists();
    
        if (complete || this->editLocation->text().isEmpty()) {
            // Don't draw any tooltip if the input is empty or invalid
            QToolTip::hideText();
        }
        else {
            // Show the tooltip just below the ```QLineEdit``` widget
            QPoint position = this->editLocation->mapToGlobal(QPoint(0, 10));
            QToolTip::showText(position, toolTipNotComplete, this->editLocation);
            }
        }
    
        return complete;
    }
    

    This looks really basic code.

    PROBLEM: But when the input is invalid, I get the tooltip shown only on on two characters (sorry, probably bad english).
    Example: When I type "ABCDEF", I will get the tooltip shown for 'A', 'C', 'E', and hidden for 'B', 'D' and 'F'. And obviously, I haven't any valid path like "AB", "ABCD" or "ABCDEF". So, the tooltip should appear every time I type a character.

    Some notes:

    • complete is computed correctly, because the "Next" button is never enabled when it should be disabled
    • if I set a QLabel visible/invisible with this logic, instead of aQToolTip, it works.
    • the toolTipNotComplete var is a static QString, but I get the same with a local string

    Thanks for any help. :)

    raven-worxR 1 Reply Last reply
    0
    • FolcoF Folco

      Hi,

      I'm using Qt5.7 32 bits bundled with MinGW, Win10 x64.

      I'm using a QLineEdit in a QWizardPage.
      I want the user to give a valid path.
      Here is a screenshot to visualize : http://www.mirari.fr/GRJw.png

      Here is the relevant part of the header:

      class PageParkLocation : public QWizardPage
      {
          public:
              PageParkLocation(QWidget* parent, QString title);
      
          private:
              QLineEdit* editLocation;
              bool isComplete() const override;
      

      As said in the QWizardPage documentation, I have overriden the isComplete method to ensure that the path is valid before the user may continue.

      Here is my code:

      bool PageParkLocation::isComplete() const
      {
          // Don't use the QDir(QString str) constructor, because the path is set to QDir::homePath() if str is empty
          QDir dir;
          dir.setPath(this->editLocation->text());
      
          // Complete is the return value, true if the user may continue, else false
          bool complete = dir.exists();
      
          if (complete || this->editLocation->text().isEmpty()) {
              // Don't draw any tooltip if the input is empty or invalid
              QToolTip::hideText();
          }
          else {
              // Show the tooltip just below the ```QLineEdit``` widget
              QPoint position = this->editLocation->mapToGlobal(QPoint(0, 10));
              QToolTip::showText(position, toolTipNotComplete, this->editLocation);
              }
          }
      
          return complete;
      }
      

      This looks really basic code.

      PROBLEM: But when the input is invalid, I get the tooltip shown only on on two characters (sorry, probably bad english).
      Example: When I type "ABCDEF", I will get the tooltip shown for 'A', 'C', 'E', and hidden for 'B', 'D' and 'F'. And obviously, I haven't any valid path like "AB", "ABCD" or "ABCDEF". So, the tooltip should appear every time I type a character.

      Some notes:

      • complete is computed correctly, because the "Next" button is never enabled when it should be disabled
      • if I set a QLabel visible/invisible with this logic, instead of aQToolTip, it works.
      • the toolTipNotComplete var is a static QString, but I get the same with a local string

      Thanks for any help. :)

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Folco
      Here is what happens:

      1. you type 'A'
      2. tooltip gets shown
      3. you type 'B' -> tooltip gets closed on key input (i guess since its a popup window)
      4. you type 'C' and show the tooltip again
      5. ...

      So using a tooltip is the wrong approach here. The actual intention of a tooltip is to show it on mouse hover.
      So you should go with your label approach.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      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