Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

What does the ellipsis (...) mean in the text QString of QAction objects?



  • Hello forums,

    I have seen example Qt source code where QActions are created with text strings that terminate with an ellipsis (...):

    QAction *openAct = new QAction(tr("&Open...", this));
    

    In the above example, I know that the actual text shown for this action will be simply "Open", with the ampersand (&) and ellipsis (...) omitted.

    I understand that the ampersand which precedes the letter "O" means that the keyboard shortcut for this action will be set to alt+O.

    However, I am still unsure what the ellipsis at the end means and what its function is. What does it do? Will setting the QAction's text string to "&Open" be any different from setting it to "&Open..."?

    Thank you very much guys!



  • Ah– I thought that the ellipsis would be ignored when displaying the text. This is why I think this:
    

    If you want QAction to display .eliipsis(...), You can override this behavior by setting a specific description with setText().

    But in any case, why would you put an ellipsis at the end of the descriptive text of the action anyways?
    

    Qt creator do have it in File menu as "New File or Project ..."
    What I feel is when intended description of action implies "many formats or multiple options and further input is required " then descriptions text can contain ellipsis(...)

    As discussed in this post usage of ellipsis is based on GUI guidelines
    https://stackoverflow.com/questions/637683/when-to-use-ellipsis-after-menu-items#:~:text=When it appears in the,associated operation can be performed.

    Does it serve some function? (like how the ampersand indicates alt-key shortcuts?)
    

    It's simply the text which following some GUI guidelines, unlike ampersand.


  • Lifetime Qt Champion

    @Yuta said in What does the ellipsis (...) mean in the text QString of QAction objects?:

    I know that the actual text shown for this action will be simply "Open", with the ampersand (&) and ellipsis (...) omitted.

    This is wrong - it shows what tr("&Open...") returns for your loaded translator and it looks like it returns '&Open'.



  • @Christian-Ehrlicher Thank you for your reply!

    Ah– I thought that the ellipsis would be ignored when displaying the text. This is why I think this:

    From QAction docs:

    The action uses a stripped version of text (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons.

    But in any case, why would you put an ellipsis at the end of the descriptive text of the action anyways? Does it serve some function? (like how the ampersand indicates alt-key shortcuts?)



  • Ah– I thought that the ellipsis would be ignored when displaying the text. This is why I think this:
    

    If you want QAction to display .eliipsis(...), You can override this behavior by setting a specific description with setText().

    But in any case, why would you put an ellipsis at the end of the descriptive text of the action anyways?
    

    Qt creator do have it in File menu as "New File or Project ..."
    What I feel is when intended description of action implies "many formats or multiple options and further input is required " then descriptions text can contain ellipsis(...)

    As discussed in this post usage of ellipsis is based on GUI guidelines
    https://stackoverflow.com/questions/637683/when-to-use-ellipsis-after-menu-items#:~:text=When it appears in the,associated operation can be performed.

    Does it serve some function? (like how the ampersand indicates alt-key shortcuts?)
    

    It's simply the text which following some GUI guidelines, unlike ampersand.



  • @nagesh Thank you for your reply– understood. So it's an UI convention/guideline as opposed to some programmatic thing. Appreciate the answer and links :)


  • Lifetime Qt Champion

    The documentation is a little bit weak here.
    The action's text stays &Open... but when the action is used for a QToolButton then the text for QToolButton is retrieved from QAction::iconText() which really strips away the ampersand and three ... if you did not call QAction::setIconText() with something else before. See https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qaction.cpp.html#_ZNK7QAction8iconTextEv



  • @Yuta said in What does the ellipsis (...) mean in the text QString of QAction objects?:

    But in any case, why would you put an ellipsis at the end of the descriptive text of the action anyways? Does it serve some function?

    It's just a convention that implies a menu entry will open a dialog box. It's a hint to the user, not something the API cares about. Like, "Open..." will trigger a file requester dialog. But "Bold" will just make the selected text bold with no additional interaction. Look at a lot of the apps you use, and you'll see the pattern now that you know what to look for.


Log in to reply