Notes on building and using GammaRay to inspect Qt internals in Krita

Alvin Wong alvin at alvinhc.com
Fri Jan 7 13:07:41 GMT 2022


Hi,

I thought I should write a message on this, since I've used GammaRay [1] 
quite a lot in the past to help inspect widget layouts, properties, 
signals and more in Krita. I find it to be a valuable tool and would 
recommend other Krita developers use it as needed. I have used it on 
Windows and Linux (AppImage build docker environment) so I'll write 
about how to build GammaRay for use on them.

If you use the system dependencies, you should also be able to use the 
distro package of GammaRay.

If you haven't tried GammaRay in the past, here is what you can do with it:

  * quickly find the name of a widget
  * diagnose widget layout issues
  * check widget hierarchy, properties, painting, etc.
  * inspect QtQuick scenes (QML)
  * inspect signal connections
  * inspect models
  * and more!

[1]: https://github.com/KDAB/GammaRay


# Windows (mingw-w64 build):

I have a script I use to build GammaRay, but first create an empty 
directory and clone the GammaRay source code inside:

     git clone -b v2.11.3 https://github.com/KDAB/GammaRay.git GammaRay

Then create a batch file named `build.cmd` in there (modify paths as 
needed) and run it:

```
set CMAKE_BIN=C:\path-to-cmake-bin-dir
set MINGW_BIN=C:\path-to-mingw-bin-dir
set QT_BIN=C:\path-to-binary-factory-deps-bin-dir
set PATH=%QT_BIN%;%MINGW_BIN%;%CMAKE_BIN%;%PATH%

mkdir build
mkdir install

pushd build
cmake ..\GammaRay -G "MinGW Makefiles" ^
     -DGAMMARAY_MULTI_BUILD=off ^
     -DGAMMARAY_BUILD_DOCS=off ^
     -DGAMMARAY_DISABLE_FEEDBACK=on ^
     -DCMAKE_BUILD_TYPE=Release ^
     -DCMAKE_INSTALL_PREFIX=../install
if errorlevel 1 (
     pause
     exit /b 1
)
cmake --build . --target install -- -j8
if errorlevel 1 (
     pause
     exit /b 1
)
pause
```

After the build is completed, the files are installed inside `install`. 
To use it, you only need to copy `bin` and `plugins` and paste them 
right inside a portable Krita package (so `bin` merges with the existing 
`bin` dir and `plugins` is created next to it). To start it, run 
`gammaray.exe krita.exe` from cmd or just drag `krita.exe` onto 
`gammaray.exe`. You can reuse the same GammaRay install on any 
binary-factory nightly or release builds.


# Linux docker environment:

Run the following in the docker to build GammaRay:

```
git clone https://github.com/KDAB/GammaRay.git -b v2.11.3 ~/GammaRay
mkdir ~/appimage-workspace/gammaray-build
cd ~/appimage-workspace/gammaray-build
cmake ~/GammaRay/ \
     -DGAMMARAY_MULTI_BUILD=off \
     -DGAMMARAY_BUILD_DOCS=off \
     -DGAMMARAY_DISABLE_FEEDBACK=on \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_INSTALL_PREFIX=~/appimage-workspace/deps/usr/ \
     -DCMAKE_PREFIX_PATH=~/appimage-workspace/deps/uar/
make -j4 install
```

After it's done, `gammaray` should be available on `PATH`. You can then 
run `gammaray krita` to use it.


Cheers,

Alvin



More information about the kimageshop mailing list