Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QApplication constructors
Qt 6.11 is out! See what's new in the release blog

QApplication constructors

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 3 Posters 5.6k Views 1 Watching
  • 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.
  • rincewindR Offline
    rincewindR Offline
    rincewind
    wrote on last edited by
    #1

    I'm not sure what is at fault here, but I just noticed that there are some inconsistencies with the QApplication constructors.

    If I type the following code in the editor:
    @
    QCoreApplication *application = new QApplication(
    @

    the code completion shows me that there are 4 different constructors, but if I press F1 on QApplication, none of the constructors in the help match the signatures of the constructors listed by the code completion.

    According to the help:
    @
    QApplication ( int & argc, char ** argv )
    QApplication ( int & argc, char ** argv, bool GUIenabled )
    QApplication ( int & argc, char ** argv, Type type )
    QApplication ( Display * display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 )
    QApplication ( Display * display, int & argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 )
    QApplication ( QApplication::QS60MainApplicationFactory factory, int & argc, char ** argv )
    @

    If I introduce a compile error, the output is:
    @
    ..\Launcher\main.cpp:15: error: no matching function for call to 'QApplication::QApplication(int, int)'
    ....\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtGui/qapplication.h:389: note: candidates are: QApplication::QApplication(const QApplication&)
    ....\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtGui/qapplication.h:130: note: QApplication::QApplication(int&, char**, QApplication::Type, int)
    ....\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtGui/qapplication.h:129: note: QApplication::QApplication(int&, char**, bool, int)
    ....\QtSDK\Desktop\Qt\4.8.0\mingw\include\QtGui/qapplication.h:128: note: QApplication::QApplication(int&, char**, int)
    @

    It looks like the code completion at least matches the compiler. The online Qt documentation matches the help in QtCreator. So, is this simply a case of incorrect documentation?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Note that the first parameter is a reference to int, not an int.

      1 Reply Last reply
      0
      • rincewindR Offline
        rincewindR Offline
        rincewind
        wrote on last edited by
        #3

        Yep, noticed that. Which is also interesting since the code
        @
        QCoreApplication *application = new QApplication(0, 0);
        @

        Compiles on Ubuntu with the Qt Creator installed from the repository and I think Qt 4.7.1. But it shouldn't...

        But that's not the point, the point is the difference between the help file and the actual code.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          I haven't verified this but the last parameter might be marked as internal (it is even named internal if I recall correctly), which means that it is hidden in the documentation (automatically by the documentation tool) but shown in Qt Creator - which just analyzes the source files and suggests what found.

          Be aware that some of the constructors are available on certain platforms only.

          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