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. Browsing the Qt source in an IDE?
Forum Updated to NodeBB v4.3 + New Features

Browsing the Qt source in an IDE?

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 5 Posters 1.6k Views 4 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.
  • U Offline
    U Offline
    Ulatekh
    wrote on 28 Jan 2022, 00:33 last edited by
    #1

    I've run into a few apparent bugs/limitations, trying to port my application to Qt, and would like to try to solve the problems by browsing the Qt source, and possibly submitting pull requests. But browsing the Qt source (with all its volume, complexity, and indirection) in a text editor is a sure route to madness. So I'm trying to get Qt Creator to the point where it can do that for me, e.g. follow symbols, find all occurences, etc.

    The latest version of the Qt source on GitLab has a CMake configuration, but the configuration failed because, as far as I can tell, the project names of Qt6 plugins conflict with the project names of Qt5 plugins. I couldn't find an easy way to disable Qt6.

    My next idea was to check out the 5.15.2 branch and try again. There's no CMake configuration there, only a .pro file. Trying to load that into Qt Creator fails because the "prompt" function (referred to by qtbase/configure.pri) isn't defined, but that was easy to hack around -- I just hacked the two relevant lines to say "val = o" and "val = y". But Qt Creator fails with a message "Error while parsing file qt.pro. Giving up.". qmake-qt5 run directly on the qt.pro file succeeds.

    How do you suggest I get the Qt source into an IDE so I can browse it sanely?

    I hope this isn't a stupid question.

    K J 2 Replies Last reply 28 Jan 2022, 05:29
    0
    • M Offline
      M Offline
      mchinand
      wrote on 28 Jan 2022, 02:20 last edited by
      #2

      Did you run perl init-repository as described in the build instructions?

      1 Reply Last reply
      0
      • U Ulatekh
        28 Jan 2022, 00:33

        I've run into a few apparent bugs/limitations, trying to port my application to Qt, and would like to try to solve the problems by browsing the Qt source, and possibly submitting pull requests. But browsing the Qt source (with all its volume, complexity, and indirection) in a text editor is a sure route to madness. So I'm trying to get Qt Creator to the point where it can do that for me, e.g. follow symbols, find all occurences, etc.

        The latest version of the Qt source on GitLab has a CMake configuration, but the configuration failed because, as far as I can tell, the project names of Qt6 plugins conflict with the project names of Qt5 plugins. I couldn't find an easy way to disable Qt6.

        My next idea was to check out the 5.15.2 branch and try again. There's no CMake configuration there, only a .pro file. Trying to load that into Qt Creator fails because the "prompt" function (referred to by qtbase/configure.pri) isn't defined, but that was easy to hack around -- I just hacked the two relevant lines to say "val = o" and "val = y". But Qt Creator fails with a message "Error while parsing file qt.pro. Giving up.". qmake-qt5 run directly on the qt.pro file succeeds.

        How do you suggest I get the Qt source into an IDE so I can browse it sanely?

        I hope this isn't a stupid question.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 28 Jan 2022, 05:29 last edited by kshegunov
        #3

        @Ulatekh said in Browsing the Qt source in an IDE?:

        The latest version of the Qt source on GitLab has a CMake configuration, but the configuration failed because, as far as I can tell, the project names of Qt6 plugins conflict with the project names of Qt5 plugins. I couldn't find an easy way to disable Qt6.

        Look here: https://wiki.qt.io/Building_Qt_5_from_Git
        and here: https://wiki.qt.io/Building_Qt_6_from_Git

        They're almost identical, but still you can glance through. As far as I know, and I may very well be wrong, the gitlab repo is just a mirror. In any case, you shouldn't have a problem with conflicts as you should not have anything in the PATH to conflict, if you do, then you need to clean this up.

        After you clone the repo, go into the source folder and select a branch (git checkout ...) then run perl init-repository to initialize the submodules, git hooks and such. An important note - you should configure a public-private ssh pair in gerrit (https://codereview.qt-project.org/) to be able to contribute, and you should supply the --codereview-username on the command line to match your user name. After all the git is initialized properly, you can start hacking away.
        Additionally if you're going to patch up qt, pass -developer-build to configure, meaning the build will not be installed. (this is specifically for what you want - to develop Qt).

        How do you suggest I get the Qt source into an IDE so I can browse it sanely?

        For Qt5, run configure, then make after that open the project file (.pro) in creator, when asked for the configuration - import build from the menu for the subprojects you want to work on. Loading the whole Qt tree is somewhat of a nonsense as you'd get to retirement before getting to do anything.

        For Qt6 import build isn't viable for the subprojects, so as before - run configure, and then import the root CMakeLists.txt project file. If you're going to be modifying QtCore then may be more steps to streamline it, but getting to load it properly in Creator should get you started at least.

        I hope this isn't a stupid question.

        Ha! Not at all! Getting the environment to cooperate is a pain point, especially when you're starting up with it and not used to the process.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        2
        • U Offline
          U Offline
          Ulatekh
          wrote on 28 Jan 2022, 05:47 last edited by
          #4

          Thanks for the pointers...I'm going through the build steps now.

          ../qt5/configure -developer-build -opensource -nomake examples -nomake tests from a qt5-build directory, with the 5.15.2 branch, errors out with a bunch of errors similar to:

          ../include/QtCore/../../../../qt5/qtbase/src/corelib/global/qfloat16.h:300:7: error: ‘numeric_limits’ is not a class template
            300 | class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
          

          I'll try this again with the dev branch tomorrow morning.
          FYI, I'm doing this under Fedora Core 35.

          K 1 Reply Last reply 28 Jan 2022, 05:50
          0
          • U Ulatekh
            28 Jan 2022, 05:47

            Thanks for the pointers...I'm going through the build steps now.

            ../qt5/configure -developer-build -opensource -nomake examples -nomake tests from a qt5-build directory, with the 5.15.2 branch, errors out with a bunch of errors similar to:

            ../include/QtCore/../../../../qt5/qtbase/src/corelib/global/qfloat16.h:300:7: error: ‘numeric_limits’ is not a class template
              300 | class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
            

            I'll try this again with the dev branch tomorrow morning.
            FYI, I'm doing this under Fedora Core 35.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 28 Jan 2022, 05:50 last edited by kshegunov
            #5

            @Ulatekh said in Browsing the Qt source in an IDE?:

            FYI, I'm doing this under Fedora Core 35.

            Compiler version is more important in this case.

            PS:
            ../qt5/configure -developer-build -opensource -nomake examples -nomake tests
            You'd want to run this directly from the source tree with Qt5.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • U Offline
              U Offline
              Ulatekh
              wrote on 31 Jan 2022, 15:55 last edited by
              #6

              ../qt5/configure -developer-build -opensource -nomake examples -nomake tests
              You'd want to run this directly from the source tree with Qt5.

              The instructions say to run configure from a separate directory.
              In any case, running configure inside the source directory gives me the same burst of errors involving numeric_limits.

              1 Reply Last reply
              0
              • U Offline
                U Offline
                Ulatekh
                wrote on 31 Jan 2022, 18:18 last edited by
                #7

                I added #include <limits> to qtbase/src/corelib/global/qfloat16.h and qtbase/src/corelib/text/qbytearraymatcher.h, and configure (in branch 5.15.2) finished.

                But now, when I try to load qt.pro into Qt Creator, I get a bunch of issues saying "Project ERROR: You cannot configure {project} separately within a top-level build", where {project} is every project in Qt.

                If I try to open qtbase/qtbase.pro in Qt Creator, I get a bunch of issues saying "Project ERROR: Unknown module(s) in QT: core gui network widgets", as well as other missing features like sharedmemory, regularexpression, opengl, freetype, etc.

                And I still get duplicate plugin project names in the dev branch, even after running perl init-repository.

                K 1 Reply Last reply 31 Jan 2022, 20:57
                0
                • U Ulatekh
                  31 Jan 2022, 18:18

                  I added #include <limits> to qtbase/src/corelib/global/qfloat16.h and qtbase/src/corelib/text/qbytearraymatcher.h, and configure (in branch 5.15.2) finished.

                  But now, when I try to load qt.pro into Qt Creator, I get a bunch of issues saying "Project ERROR: You cannot configure {project} separately within a top-level build", where {project} is every project in Qt.

                  If I try to open qtbase/qtbase.pro in Qt Creator, I get a bunch of issues saying "Project ERROR: Unknown module(s) in QT: core gui network widgets", as well as other missing features like sharedmemory, regularexpression, opengl, freetype, etc.

                  And I still get duplicate plugin project names in the dev branch, even after running perl init-repository.

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 31 Jan 2022, 20:57 last edited by
                  #8

                  @Ulatekh said in Browsing the Qt source in an IDE?:

                  But now, when I try to load qt.pro into Qt Creator, I get a bunch of issues saying "Project ERROR: You cannot configure {project} separately within a top-level build", where {project} is every project in Qt.

                  @kshegunov said in Browsing the Qt source in an IDE?:

                  For Qt5, run configure, then make after that open the project file (.pro) in creator, when asked for the configuration - import build from the menu for the subprojects you want to work on. Loading the whole Qt tree is somewhat of a nonsense as you'd get to retirement before getting to do anything.

                  Don't create your own separate configuration, use the one that was used when you'd built from the command line.
                  (Make sure to deselect everything in Creator, then click the "Import build" button)

                  And I still get duplicate plugin project names in the dev branch, even after running perl init-repository.

                  The dev branch is Qt 6.3 or Qt 6.4, so use Qt 5.15 instead.

                  Read and abide by the Qt Code of Conduct

                  U 1 Reply Last reply 31 Jan 2022, 22:03
                  0
                  • K kshegunov
                    31 Jan 2022, 20:57

                    @Ulatekh said in Browsing the Qt source in an IDE?:

                    But now, when I try to load qt.pro into Qt Creator, I get a bunch of issues saying "Project ERROR: You cannot configure {project} separately within a top-level build", where {project} is every project in Qt.

                    @kshegunov said in Browsing the Qt source in an IDE?:

                    For Qt5, run configure, then make after that open the project file (.pro) in creator, when asked for the configuration - import build from the menu for the subprojects you want to work on. Loading the whole Qt tree is somewhat of a nonsense as you'd get to retirement before getting to do anything.

                    Don't create your own separate configuration, use the one that was used when you'd built from the command line.
                    (Make sure to deselect everything in Creator, then click the "Import build" button)

                    And I still get duplicate plugin project names in the dev branch, even after running perl init-repository.

                    The dev branch is Qt 6.3 or Qt 6.4, so use Qt 5.15 instead.

                    U Offline
                    U Offline
                    Ulatekh
                    wrote on 31 Jan 2022, 22:03 last edited by
                    #9

                    I'm not sure what you're asking me to do.
                    When I load qt.pro in Qt Creator, I "import build" from the qt5-build directory I created with configure, and deselect everything else.

                    However, this time, I built qtbase (using nice -10 make -j 8 module-qtbase from inside my qt5-build directory), and now, when I load qtbase/qtbase.pro directly, it still logs lots of errors to "Issues" (e.g. "No module claims plugin type 'mockplugin'", "Cannot find feature sdk", and "docker-compose: Command not found", among many others), but at least the qtbase source loads and seems to be browsable!
                    Not sure why building was necessary to get the project file to load. Maybe it was a coincidence.

                    I'm fine with browsing version 5.15.2, since that's what I'm using in my project anyway...though I should probably get a development branch building if I'm going to submit bug fixes. (I'm up to 6 things that appear to need fixing.)

                    K 1 Reply Last reply 1 Feb 2022, 13:36
                    0
                    • U Ulatekh
                      28 Jan 2022, 00:33

                      I've run into a few apparent bugs/limitations, trying to port my application to Qt, and would like to try to solve the problems by browsing the Qt source, and possibly submitting pull requests. But browsing the Qt source (with all its volume, complexity, and indirection) in a text editor is a sure route to madness. So I'm trying to get Qt Creator to the point where it can do that for me, e.g. follow symbols, find all occurences, etc.

                      The latest version of the Qt source on GitLab has a CMake configuration, but the configuration failed because, as far as I can tell, the project names of Qt6 plugins conflict with the project names of Qt5 plugins. I couldn't find an easy way to disable Qt6.

                      My next idea was to check out the 5.15.2 branch and try again. There's no CMake configuration there, only a .pro file. Trying to load that into Qt Creator fails because the "prompt" function (referred to by qtbase/configure.pri) isn't defined, but that was easy to hack around -- I just hacked the two relevant lines to say "val = o" and "val = y". But Qt Creator fails with a message "Error while parsing file qt.pro. Giving up.". qmake-qt5 run directly on the qt.pro file succeeds.

                      How do you suggest I get the Qt source into an IDE so I can browse it sanely?

                      I hope this isn't a stupid question.

                      J Offline
                      J Offline
                      JKSH
                      Moderators
                      wrote on 1 Feb 2022, 12:25 last edited by
                      #10

                      @Ulatekh said in Browsing the Qt source in an IDE?:

                      How do you suggest I get the Qt source into an IDE so I can browse it sanely?

                      I don't have anything else to add to @kshegunov's tips here. If you want to try a different approach, this website lets you navigate/search through the Qt source code without an IDE: https://code.woboq.org/qt5/

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      0
                      • U Ulatekh
                        31 Jan 2022, 22:03

                        I'm not sure what you're asking me to do.
                        When I load qt.pro in Qt Creator, I "import build" from the qt5-build directory I created with configure, and deselect everything else.

                        However, this time, I built qtbase (using nice -10 make -j 8 module-qtbase from inside my qt5-build directory), and now, when I load qtbase/qtbase.pro directly, it still logs lots of errors to "Issues" (e.g. "No module claims plugin type 'mockplugin'", "Cannot find feature sdk", and "docker-compose: Command not found", among many others), but at least the qtbase source loads and seems to be browsable!
                        Not sure why building was necessary to get the project file to load. Maybe it was a coincidence.

                        I'm fine with browsing version 5.15.2, since that's what I'm using in my project anyway...though I should probably get a development branch building if I'm going to submit bug fixes. (I'm up to 6 things that appear to need fixing.)

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 1 Feb 2022, 13:36 last edited by kshegunov 2 Jan 2022, 13:37
                        #11

                        @Ulatekh said in Browsing the Qt source in an IDE?:

                        I'm not sure what you're asking me to do.

                        To not mix Qt5 and Qt6 code.

                        1. If you're going to do a fix for Qt5 only:
                          Clone from git, go to the root dir and checkout 5.15 as a branch. Run init-repository and configure (use qmake to build). Then import the (sub)projects into creator.

                        2. If you're going to do a fix for Qt5 and Qt6 (or only for Qt6)
                          Clone from git, go to the root dir checkout dev as a branch. Run init-repository and configure (use cmake(!) to build). Qt6 isn't buildable with qmake as far as I know. Then load the root project and import the build from the build directory. You can't import (sub)projects with cmake as it works differently.

                        Not sure why building was necessary to get the project file to load. Maybe it was a coincidence.

                        It's not, but the makefiles need to be present for the (qmake) "Import build" to work, and the easiest way to get them is to build once from the command line after configuring, and then import whatever you want to work on.

                        I'm fine with browsing version 5.15.2, since that's what I'm using in my project anyway...though I should probably get a development branch building if I'm going to submit bug fixes. (I'm up to 6 things that appear to need fixing.)

                        Yes, but in a separate source/build directory as mentioned above.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        2
                        • U Offline
                          U Offline
                          Ulatekh
                          wrote on 1 Feb 2022, 19:43 last edited by
                          #12

                          If you're going to do a fix for Qt5 only

                          I assume I'd want my fixes to apply to all relevant versions?

                          If you're going to do a fix for [...] Qt6

                          As I stated above, I can't configure the dev branch – it reports that some Qt6 plugins have the same project name as Qt5 plugins, and errors out. I would like to know how to get past this. It seems like a bug in the cmake configuration.

                          In any case, I can now browse Qt5 in an IDE under Fedora Core Linux, I've built qtbase (so far, the only part of Qt I'm using) with MSYS2/MinGW under MS Windows, and I can link my application to my hand-built qtbase, allowing me to set breakpoints and single-step through Qt & all that.

                          I assume all fixes have to be submitted here? My first contribution will be simple...to get 5.15.2 (and maybe dev...don't know yet) to configure, under both Linux and MinGW, #include <limits> had to be added to qtbase's src/corelib/global/qfloat16.h, src/corelib/text/qbytearraymatcher.h, and src/corelib/tools/qoffsetstringarray_p.h. Maybe there's a better place to add that header-inclusion.

                          Thanks to everyone for the help so far!

                          K 1 Reply Last reply 1 Feb 2022, 19:46
                          0
                          • U Ulatekh
                            1 Feb 2022, 19:43

                            If you're going to do a fix for Qt5 only

                            I assume I'd want my fixes to apply to all relevant versions?

                            If you're going to do a fix for [...] Qt6

                            As I stated above, I can't configure the dev branch – it reports that some Qt6 plugins have the same project name as Qt5 plugins, and errors out. I would like to know how to get past this. It seems like a bug in the cmake configuration.

                            In any case, I can now browse Qt5 in an IDE under Fedora Core Linux, I've built qtbase (so far, the only part of Qt I'm using) with MSYS2/MinGW under MS Windows, and I can link my application to my hand-built qtbase, allowing me to set breakpoints and single-step through Qt & all that.

                            I assume all fixes have to be submitted here? My first contribution will be simple...to get 5.15.2 (and maybe dev...don't know yet) to configure, under both Linux and MinGW, #include <limits> had to be added to qtbase's src/corelib/global/qfloat16.h, src/corelib/text/qbytearraymatcher.h, and src/corelib/tools/qoffsetstringarray_p.h. Maybe there's a better place to add that header-inclusion.

                            Thanks to everyone for the help so far!

                            K Offline
                            K Offline
                            kshegunov
                            Moderators
                            wrote on 1 Feb 2022, 19:46 last edited by kshegunov 2 Jan 2022, 20:02
                            #13

                            @Ulatekh said in Browsing the Qt source in an IDE?:

                            I assume I'd want my fixes to apply to all relevant versions?

                            Obviously we all will want that, however this is done by cherry picking through gerrit. My original statement stands - do not mix Qt5 and Qt6 code, fixes for both - Qt6 code, fixes for Qt5 only - Qt5 code.

                            I assume all fixes have to be submitted here?

                            Yes.

                            My first contribution will be simple...to get 5.15.2 (and maybe dev...don't know yet) to configure, under both Linux and MinGW, #include <limits> had to be added to qtbase's src/corelib/global/qfloat16.h, src/corelib/text/qbytearraymatcher.h, and src/corelib/tools/qoffsetstringarray_p.h. Maybe there's a better place to add that header-inclusion.

                            Is it this one?
                            https://codereview.qt-project.org/c/qt-creator/qt-creator/+/346438

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply
                            0
                            • U Offline
                              U Offline
                              Ulatekh
                              wrote on 1 Feb 2022, 20:09 last edited by
                              #14

                              fixes for both - Qt6 code

                              I will, as soon as I can configure Qt6 successfully...

                              Is it this one?

                              No, that's for src/plugins/qmlprofiler/qmlevent.h. I listed the 3 header files that need #include <limits> above.

                              1 Reply Last reply
                              0
                              • U Offline
                                U Offline
                                Ulatekh
                                wrote on 2 Feb 2022, 02:16 last edited by
                                #15

                                OK, I've submitted my first merge request!

                                I have two more changes that are appropriate for the 5.15.2 branch, but I apparently don't have permission to push to refs/for/5.15.2...not sure if that's even generally accepted. (Neither are applicable to the dev branch.)

                                1 Reply Last reply
                                1
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 2 Feb 2022, 20:00 last edited by
                                  #16

                                  Hi,

                                  For 5.15 patches, the ref is 5.15. 5.15.2 has been closed a long time ago.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  1
                                  • U Offline
                                    U Offline
                                    Ulatekh
                                    wrote on 3 Feb 2022, 04:32 last edited by
                                    #17

                                    For 5.15 patches, the ref is 5.15. 5.15.2 has been closed a long time ago.

                                    Do I need permission? git push gerrit HEAD:refs/for/5.15 gets me remote: You need 'Create Change' rights to upload code review requests. and ! [remote rejected] HEAD -> refs/for/5.15 (prohibited by Gerrit: not permitted: create change on refs/heads/5.15).

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 3 Feb 2022, 21:07 last edited by
                                      #18

                                      My bad, I forgot that the 5.15 branch has been closed to public commits.

                                      See here.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0
                                      • U Offline
                                        U Offline
                                        Ulatekh
                                        wrote on 4 Feb 2022, 23:12 last edited by
                                        #19

                                        Thanks for letting me know.

                                        In case anyone's interested, I'm putting my 5.15.2 bug fixes here.

                                        1 Reply Last reply
                                        0
                                        • U Offline
                                          U Offline
                                          Ulatekh
                                          wrote on 15 Feb 2022, 21:47 last edited by
                                          #20

                                          So...no further ideas for getting the dev branch to configure without error?
                                          Am I the only one seeing this?

                                          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