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. Is it possible to both set a tooltip string AND disable tooltip?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to both set a tooltip string AND disable tooltip?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 695 Views
  • 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
    adamsmith
    wrote on 27 Jul 2019, 11:32 last edited by
    #1

    I want to store some information that is specific to the button that is created and need to be passed on to the next function. Currently I am doing this by setting the tooltip of the QPushButton and then retrieving it in the function that is connected to the QPushButton click action. I do not want the user to see the information stored inside the tooltip, it is not private or sensitive information but it is unnecessary of the user to see it.

    Is it possible to set the tooltip duration to 0 or to disable the tooltip but have the stored information inside the tooltip string still there?

    My situation: I have created a table using QTableWidget and I enter information from different files into the table. The information in the row cells has this format: "date created" "expire date" "text of an item" "category". The category has the same name as the file that the other info is stored in (e.g. "2019-01-01" "2019-02-01" "milk" "delete".On the very last row cell (as far right>>> on the table as I can get) I have a delete button that scraps the row of information (such as the name of the file that contained all other info) and then deletes the correct parts of the selected file (e.g. containing 2019-01-01, 2019-02-01 and milk.)

    I do not want people to hover over the delete button and see "25;223" (I use ; to separate row ; item pos)

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 27 Jul 2019, 11:39 last edited by VRonin
      #2

      Instead of storing the data in the tooltip just store it in a custom property: https://doc.qt.io/qt-5/qobject.html#setProperty

      button->setProperty("MyData",qMakePair(25,223));
      qDebug() << button->property("MyData").value<QPair<int,int> >();


      My situation: I have created a table using QTableWidget

      It feels however you are using the wrong tool for the job in the first place. If my memory doesn't fail me, @kshegunov implemented a very elegant delegate to implement a delete/edit button so I'd ask him if he can share the link to the source of that solution

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • A Offline
        A Offline
        adamsmith
        wrote on 27 Jul 2019, 11:46 last edited by
        #3

        setting property worked perfectly, thanks!

        1 Reply Last reply
        0

        1/3

        27 Jul 2019, 11:32

        • Login

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