Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QDialog: how to use question mark (?) button?

Tags:

qt

pyqt

pyside

By default, QDialog windows have a question mark pushbutton in the upper-right corner. When I press it, the mouse cursor is changed to the 'Forbidden' cursor, and nothing else seems to happen.

While there is lots of information generated from those who want to remove the question mark (at least three SO threads are devoted to the topic), the documentation for QDialog doesn't have anything about how to actually use it.

How do I get my application to display information when the question mark is clicked? E.g., how do I get the clicked signal from the button? Better yet, where is this button documented?

like image 930
eric Avatar asked Nov 17 '14 15:11

eric


People also ask

Who can see the question mark in a qdialog?

Only users with topic management privileges can see it. Hi! In QDialog we have question mark button. How can i use it to for example messegebox. Take a look at the QWhatsThis class.

How do I use dialogs in Qt?

There are many dialogs which follow the simple pattern we just saw -- a message with buttons with which you can accept or cancel the dialog. While you can construct these dialogs yourself, Qt also provides a built-in message dialog class called QMessageBox. This can be used to create information, warning, about or question dialogs.

How to remove question marks by default for dialogs in qapplication?

The following way to remove question marks by default for all the dialogs in application could be used: Attach the following event filter to QApplication somewhere at the start of your program:

Who can see deleted topic in qdialog?

This topic has been deleted. Only users with topic management privileges can see it. Hi! In QDialog we have question mark button. How can i use it to for example messegebox.


2 Answers

The other answers were a bit misleading for me, focusing only on catching the question mark event, but not explaining the normal usage.

When this button is clicked and WhatsThisMode is triggered, the elements of the dialog are supposed to give info about themselves. And if mouse hovers over an element that supports this info then the pointer will become a pointing arrow with a question mark (on Windows at least), with a tooltip message displayed on mouse click.

Here's how to achieve it in PySide:

someWidget.setWhatsThis("Help on widget")

QWhatsThis documentation for PySide and Qt5 is also available.

like image 130
Andris Avatar answered Nov 09 '22 04:11

Andris


It is not a button documented by Qt. You can detect this by catching events and checking event type:

http://qt-project.org/doc/qt-5/qevent.html#Type-enum

There are different types as QEvent::EnterWhatsThisMode QEvent::WhatsThisClicked and so on. I achieved something similar to what are you looking for using event filter in mainwindow.

if(event->type() == QEvent::EnterWhatsThisMode)
    qDebug() << "click";

I saw "click" when I clicked on ? button.

like image 45
Kosovan Avatar answered Nov 09 '22 04:11

Kosovan