[Solved] How To Work With The ? Button

Hello everyone,

How does one go about working with the ? Button that is default on the QDialog widgets? It seems like the idea is to set some text to each widget that pops up when the user clicks the ? Button and then clicks on one of your widgets. The problem is that I can’t figure out how to use this feature. Everything I’ve tried so far returns the “not a function” error. How do you set the ? Button text to QDialog Widgets? Also, how do you disable the ? Button?

Thanks in advance for your time and reply.

Hi,

This is part of the Qt Help System.

For some reasons I made it a habit to assign a custom toolTip to the label associated with the widget.
Most of them are an RMathLineEdit and those use the toolTip already.

The use of statusTip under QCAD is basically limited to tool buttons and for a few user tools: CrankWheel.ui, PolylineBreakSymbol.ui
Only PreferencesPage.ui has a single statusTip.

The third standard option is whatsThis.
I have played with this in some dialog’s of my custom tools.
The idea was to provide more info than what is displayed with a tooltip without calling an external document.

If I remember correctly then I removed them from the release of FlexPainter. :frowning:
whatsThis doesn’t play well with the QCAD Dark Mode (White on white).
It is untested if that is custom handled in themes by Pete Vickerstaff (petevick) or his QCAD Theme Designer.

Perhaps it is related to the Qt Designer I use but for me the button with the arrow and the question mark is not a default.
Then again, it is not the first time that I need to manually edit the UI xml to include some standard Qt or QCAD features.
For example the SaveContents = false parameter under QCAD.

:arrow_right: How does the so said ‘default implementation’ looks like in xml for your QDialog’s :question:

For me whatsThis is functional in the Default QCAD theme using the right mouse button and then opt for “What’s This?”.
But then I don’t really need them because I am the developer and the sole user of those tools. :laughing:

From the Qt description the question mark button would set the interface to the “What’s This?” mode.
Shift+F1 doesn’t seems to work … On Win … Under QCAD.

Disabling a button would be the same as for any other button.
Query the widget from the dialog and set it disabled or hidden.
I think it also should be possible to eliminate it completely from the xml.

Regards,
CVH

Wow, this aspect of Qt seems so much bigger than what I was expecting. Do you think you could post some code snippets for each of the three options? I was trying to use QWhatsThis but the same functions on the documentation don’t want to work with the scripting environment. I was expecting (if it did work) to click on the ? Button, then click on one of the QWidgets, and it would pop up whatever text I put in. Is that QWhatsThis or one of the other ones? What do the other two ones do? Does one of them popup the tutorial help document thing like on other programs?

Is the statusTip within PreferencesPage.ui the red text near the top?

I haven’t had to edit the xml directly for any QDialogs yet so I don’t really know. At first glance there doesn’t appear to be anything in it for the ? button. I attached a default one for you to look at. I’m using the Qt Designer 5.13.2 (MSVC 2015 64-bit) that was installed along with Qt when I was trying to figure out how to compile the source. It installed a bunch of different versions plus Qt Assistant, Qt Creator, Qt Linguist, and a number of terminals. The ? Button is always on all of the QDialogs for me.
default.ui (1.48 KB)

No, sorry, the information was incomplete because every preference UI file has the same name.
:arrow_right: A single occurrence of a statusTip can be found in:
…\scripts\Edit\AppPreferences\GraphicsViewPreferences\PreferencesPage.ui
For the QCheckBox called ‘SystemCursors’.
See example below.

But it doesn’t show when hovering over that preference …
I suspect that this doesn’t work on a Win system because a Dialog is always modal and it can not address the QCAD GUI Status Bar.
A dialog itself usually has no Status Bar under QCAD.
Although it is a standard QWidget, I don’t see a way of including it in a QDialog using my copy of Qt Designer (5.11.1).
# Found it # Programmatically, not feasible with Qt Designer.

There is no code to be shared except for the entries in the UI xml.
It is just a property holding a string value.

       <item>
        <widget class="QCheckBox" name="SystemCursors">
         <property name="statusTip">
          <string>This can be used if cursors are not visible on external monitors</string>
         </property>
         <property name="text">
          <string>Use system cursors</string>
         </property>
         <property name="RequiresRestart" stdset="0">
          <bool>true</bool>
         </property>
        </widget>
       </item>

In Qt Designer you could fill in some strings for: toolTip, statusTip or whatsThis.
Or you could set/update/clear them programmatically for every QWidget:
qwidget::toolTip ; qwidget::statusTip ; qwidget::whatsThis

If any, displaying the toolTip is a default behaviour under QCAD, but again, this can be configured.
If any, the whatsThis text pops up after a right click and opting for What’s This in the context menu.



Also notice that we don’t have the [Arrow+?] or [?] button by default as in your case.
And not only for me, have a look at the screen capture by users TrevorW or artisanicview as example.
That has probably to do with your custom compilation of the QCAD source code or the Qt version (5.13.2).

You could test it by defining a whatsThis string for a QWidget, hit the button and then indicate your QWidget.

No there isn’t anything about that button.
All this is probably a standard Qt implementation on a higher level.

Do all the QCAD dialogs have this button?
Could you attach a capture of for example the Rotate Option dialog?

Some online search results:
how-to-work-with
how-can-i-hide-delete
How do I add a statusbar

Side Note:
Tile2Hatch is a tool that can convert anything we can draw in a defined right quadrilateral area (A tile) to a hatch pattern file.
Tessellating the tile in all directions to infinity.
Works perfectly achieving the highest art there is but it is kinda dead in the water.
As long as the QCAD hatch rendering engine is not enhanced in a major way it serves no use.
At the moment a pattern is handled as:

  • Drawing an amount of parallel endless lines with each a custom line pattern, almost endless parallels depending the angle (Cloning load).
    Converting the patterned lines to individual line segments and/or dots.
    All data is then clipped to the hatch boundary, removing or trimming many/most of those segments and/or dots.
    Defining Inside/outside/crossing for each segment/dot against all boundary edges as lines or approximated by lines.
    And that for every entry in a hatch pattern file.

This is a very time-consuming approach with large to very large data sets and not really mathematically stable in the long run.
At some point the rendering engine times out (125-10000 ms by preference) or it fails completely.
Fine for something as “ANSI31” but it already starts to fail for some basic standard patterns like: “AR-CONC” or “GRAVEL”.

The only thing we learned from this is to keep our hatch pattern origin near the hatched area in QCAD.
Two other tools have emerged from the gathered knowledge: BHT & BMP both by John Hyslop but both limited/restricted in some way.

Regards,
CVH

Thank you very much for your reply/help. I have it figured out now. I was trying to set it programmatically using the functions but it wasn’t working. The fix is similar to the one in my other OKButton role thread where you can’t use the functions and instead have to edit the properties directly. Instead of myWidget.whatsThis(“test”) use myWidget.whatsThis = “test”. I also didn’t know it was an option within Qt Designer (which will probably be better than doing it programmatically. At any rate, I have it figured out now. Thank you again.

Sure, see attached screenshots. Note that these screenshots are taken from QCAD Pro and not from my compiled version. The ? button is not shown on the rotate options but it is shown on the About dialog. Maybe it’s a Windows thing?


Hi,

The story is not complete.
I now see the [?] button too on the about dialog.
In About.js we can detect that this dialog is created with:

var dialog = this.createWidget("AboutDialog.ui");

A helper function of EAction for WidgetFactory.createWidget

We would expect a dialog is created with this.createDialog

Something to investigate further …
The difference between createWidget and createDialog for this matter seems to be:

    var flags = dialog.windowFlags();
    flags = makeQtWindowFlags(flags & ~(Qt.WindowContextHelpButtonHint));
    dialog.setWindowFlags(flags);

Found here: how-can-i-hide-delete-the-help-button

Also detected other dialogs that are created as widget.
e.g. CharacterMapDialog

The (most recent) Qt reference qwidget::whatsThis lists a property and a function to set it.
What I sometimes tend to do is halt the code after some specific point in the debugger mode.
I can then lookup the properties and functions of the object of interest.
Looking for: setStatusTip(), setToolTip(), setWhatsThis() …
It then seems that the setters are not implemented in the Qt version we use.
So we need to set the properties in direct.


I was able to implement a status bar in a dialog …
But it doesn’t display statusTip’s right out the box. :frowning:

Regards,
CVH

Yeah, I was using createWidget() for all of my dialogs which is why I assumed the ? button being there was the default. Note that the tutorials show createWidget() being used. You can find the specific tutorial here: QCAD: Persistent Widgets

I should probably learn how to use the debugger mode. I tried it once awhile back but thought it was too slow for my tastes going through each line of code one by one and never tried it again. I tend to just run the program with the -enable-script-debugger flag and have it tell me straightaway what is wrong. If that’s not giving me enough info for whatever reason, I’ve been using the qDebug() functions throughout the script to print out info and determine what is going wrong. I didn’t know the debugger mode could tell you which functions are available. I’ll have to look into that eventually.

I was thinking the setters not being implemented had to do with the scripting environment. I thought the same thing when I was figuring out the OK button role and looked up an archived Qt documentation for the version of Qt QCAD is using and all the setters are there. Unless I was looking at the wrong thing or something.

:open_mouth: e_surprised e_confused

Simply add a line with debugger; to halt the code there.
Or it would halt at the first exception before that … And at every other exception of course :wink:

qDebug(), qWarning(), … Don’t really work for me on a Win based system.
Then I need to start QCAD from the OS command line and Stream the output to a log file, opening that afterwards.

I tend to exploit EAction.handleUserMessage() .handleUserInfo() and .handleUserWarning() wherever needed.
Because that displays the relevant information directly on the Command History.
For that reason my Command Line widget is somewhat higher (longer) and docked at the right side.

Yep, seen that in investigating code for this topic and then I understood:

:laughing:

Probably not but who can tell.
Sometimes it is easier to verify than to keep on trying what should work but does not.
Online help may then make you run in circles.

Regards,
CVH