Browsing the Qt source in an IDE?
-
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.
-
Did you run
perl init-repository
as described in the build instructions? -
@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_GitThey'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 runperl 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
, thenmake
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.
-
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. -
@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. -
../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, runningconfigure
inside the source directory gives me the same burst of errors involvingnumeric_limits
. -
I added
#include <limits>
toqtbase/src/corelib/global/qfloat16.h
andqtbase/src/corelib/text/qbytearraymatcher.h
, andconfigure
(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 runningperl init-repository
. -
@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.
-
I'm not sure what you're asking me to do.
When I loadqt.pro
in Qt Creator, I "import build" from theqt5-build
directory I created withconfigure
, and deselect everything else.However, this time, I built qtbase (using
nice -10 make -j 8 module-qtbase
from inside myqt5-build
directory), and now, when I loadqtbase/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.)
-
@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/
-
@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.
-
If you're going to do a fix for Qt5 only:
Clone from git, go to the root dir and checkout5.15
as a branch. Runinit-repository
and configure (useqmake
to build). Then import the (sub)projects into creator. -
If you're going to do a fix for Qt5 and Qt6 (or only for Qt6)
Clone from git, go to the root dir checkoutdev
as a branch. Runinit-repository
and configure (usecmake
(!) to build). Qt6 isn't buildable withqmake
as far as I know. Then load the root project and import the build from the build directory. You can't import (sub)projects withcmake
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.
-
-
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 maybedev
...don't know yet) to configure, under both Linux and MinGW,#include <limits>
had to be added to qtbase'ssrc/corelib/global/qfloat16.h
,src/corelib/text/qbytearraymatcher.h
, andsrc/corelib/tools/qoffsetstringarray_p.h
. Maybe there's a better place to add that header-inclusion.Thanks to everyone for the help so far!
-
@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 -
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 thedev
branch.) -
Hi,
For 5.15 patches, the ref is 5.15. 5.15.2 has been closed a long time ago.
-
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 meremote: 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)
.