Solved Is it possible to both set a tooltip string AND disable tooltip?
-
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)
-
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
-
setting property worked perfectly, thanks!