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 "About Qt" dialog HTML or text content available in Qt5 API?
QtWS25 Last Chance

Is "About Qt" dialog HTML or text content available in Qt5 API?

Scheduled Pinned Locked Moved Solved General and Desktop
about qtaboutqtqt version
10 Posts 6 Posters 5.4k 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.
  • P Offline
    P Offline
    Phil_W
    wrote on last edited by Phil_W
    #1

    This public static method shows a dialog with Qt version and licensing information:

    • void QMessageBox::aboutQt (
      QWidget* parent, const QString& title = QString());

    Within our Qt application, we need to get our hands on the HTML (or at least text) string displayed in that dialog. Is there a way to do this?

    Aside: We really do need what I mentioned above. But short of that, it would be good if the content of the "About Qt" dialog was selectable and copyable. (Currently, it apparently isn't).

    We're using Qt 5.5.1 on Windows with Visual Studio 2010 SP1.

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This text is not exposed by any public API. There's also no direct programmatic way to get a pointer to the message box (apart from some ugly tricks with top level windows list). If you want to you can copy the text from the sources and show however you like.
      The message box uses default text interaction flags which depend on the style. If you want a message box with selectable text you can roll your own and set Qt::TextSelectableByMouse flag on it.

      1 Reply Last reply
      5
      • tekojoT Offline
        tekojoT Offline
        tekojo
        wrote on last edited by
        #3

        Hi @Phil_W
        I just have to ask what you would change in the About Qt text?
        I mean what is the specific need? And is it something more common, as I haven't run into this before.

        1 Reply Last reply
        4
        • P Offline
          P Offline
          Phil_W
          wrote on last edited by
          #4

          We have a requirement to provide information about all of our 3rd party libraries in a copyable form. (A read-only QTextEdit, with basic HTML formatting). That is, so that it can be selected, copied and pasted (e.g. into an e-mail message). We don't need to change anything in the About Qt text, as such.

          This image shows just the top portion of such a document (in a read-only QTextEdit widget). Notice that, for now, the Qt information can't be included in the document. Instead, we can show the Qt information only with a button (see, at bottom).

          About RiverWare Dialog

          1 Reply Last reply
          1
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            HI
            You can just grab it from the qmessagebox.cpp

            void QMessageBox::aboutQt(QWidget *parent, const QString &title)
            {
                QString translatedTextAboutQtCaption;
                translatedTextAboutQtCaption = QMessageBox::tr(
                    "<h3>About Qt</h3>"
                    "<p>This program uses Qt version %1.</p>"
                    ).arg(QLatin1String(QT_VERSION_STR));
                QString translatedTextAboutQtText;
                translatedTextAboutQtText = QMessageBox::tr(
                    "<p>Qt is a C++ toolkit for cross-platform application "
                    "development.</p>"
                    "<p>Qt provides single-source portability across all major desktop "
                    "operating systems. It is also available for embedded Linux and other "
                    "embedded and mobile operating systems.</p>"
                    "<p>Qt is available under three different licensing options designed "
                    "to accommodate the needs of our various users.</p>"
                    "<p>Qt licensed under our commercial license agreement is appropriate "
                    "for development of proprietary/commercial software where you do not "
                    "want to share any source code with third parties or otherwise cannot "
                    "comply with the terms of the GNU LGPL version 3 or GNU LGPL version 2.1.</p>"
                    "<p>Qt licensed under the GNU LGPL version 3 is appropriate for the "
                    "development of Qt&nbsp;applications provided you can comply with the terms "
                    "and conditions of the GNU LGPL version 3.</p>"
                    "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
                    "development of Qt&nbsp;applications provided you can comply with the terms "
                    "and conditions of the GNU LGPL version 2.1.</p>"
                    "<p>Please see <a href=\"http://%2/\">%2</a> "
                    "for an overview of Qt licensing.</p>"
                    "<p>Copyright (C) %1 The Qt Company Ltd and other "
                    "contributors.</p>"
                    "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"
                    "<p>Qt is The Qt Company Ltd product developed as an open source "
                    "project. See <a href=\"http://%3/\">%3</a> for more information.</p>"
                    ).arg(QLatin1String("2015"),
                          QLatin1String("qt.io/licensing"),
                          QLatin1String("qt.io"));
                QMessageBox *msgBox = new QMessageBox(parent);
                msgBox->setAttribute(Qt::WA_DeleteOnClose);
                msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
                msgBox->setText(translatedTextAboutQtCaption);
                msgBox->setInformativeText(translatedTextAboutQtText);
            
                QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
            
            1 Reply Last reply
            3
            • P Offline
              P Offline
              Phil_W
              wrote on last edited by Phil_W
              #6

              Thanks, that's what we'll do. If nothing is added to Qt in future versions to support this, we'll just have to manually grab this text each time we upgrade to a new version of Qt.

              There might also be some use in having this "About Qt" content at a permanent URL on a public Qt website, distinct for each version (or perhaps with a visible "GET" argument in the URL with the QT_VERSION_STR / qVersion() text).

              It might also be good to have the text in the About Qt dialog selectable (copyable) -- but read-only, of course.

              mrjjM 1 Reply Last reply
              1
              • P Phil_W

                Thanks, that's what we'll do. If nothing is added to Qt in future versions to support this, we'll just have to manually grab this text each time we upgrade to a new version of Qt.

                There might also be some use in having this "About Qt" content at a permanent URL on a public Qt website, distinct for each version (or perhaps with a visible "GET" argument in the URL with the QT_VERSION_STR / qVersion() text).

                It might also be good to have the text in the About Qt dialog selectable (copyable) -- but read-only, of course.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @Phil_W
                Well its the first time I ever saw anyone ask for it so unless you open report and vote for it,
                it's unlikely it will change in newer versions.

                Also, it should possible to grab from code but it will fiddle with internal
                objects and might break anyway on next upgrade so maybe just taking the lines
                is the best solution.

                1 Reply Last reply
                2
                • F Offline
                  F Offline
                  FlorianWolters
                  wrote on last edited by
                  #8

                  Sorry for replying on such an old thread, but I'm currently facing a similar challenge. I am fine with the text of the QMessageBox::aboutQt(), but I would like to remove the hyperlinks. I got the requirement that it should not be possible to open a web browser using the GUI application. Is there anything I can do to deactivate the URLs? Do I really have to copy the text from the source of Qt and create my own dialog in order to get rid of the clickable links?

                  GrecKoG 1 Reply Last reply
                  0
                  • F FlorianWolters

                    Sorry for replying on such an old thread, but I'm currently facing a similar challenge. I am fine with the text of the QMessageBox::aboutQt(), but I would like to remove the hyperlinks. I got the requirement that it should not be possible to open a web browser using the GUI application. Is there anything I can do to deactivate the URLs? Do I really have to copy the text from the source of Qt and create my own dialog in order to get rid of the clickable links?

                    GrecKoG Offline
                    GrecKoG Offline
                    GrecKo
                    Qt Champions 2018
                    wrote on last edited by
                    #9

                    @FlorianWolters Another alternative would be disabling QDesktopServices entirely by compiling Qt yourself and defining QT_NO_DESKTOPSERVICES for it.

                    If you can't do that you can also add a url handler to QDesktopServices doing nothing:

                    class DummyUrlHandler : public QObject
                    {
                      Q_OBJECT
                    public slots:
                      void handleUrl(const QUrl &) { }
                    };
                    
                    // at the start of your application
                    DummyUrlHandler handler;
                    QDesktopServices::setUrlHandler("http", &handler, "handleUrl");
                    QDesktopServices::setUrlHandler("https", &handler, "handleUrl");
                    // add other schemes susceptible to open your browser
                    
                    1 Reply Last reply
                    3
                    • F Offline
                      F Offline
                      FlorianWolters
                      wrote on last edited by
                      #10

                      @GrecKo Thank you very much. That is a much cleaner solution and much more secure. I wrote a small class that also deals with unregistration in a RAII way today. Works like a charm.

                      1 Reply Last reply
                      0

                      • Login

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