Testing
How to quickly test a plasma widget
plasmawindowed
There are 3 ways to test a widget.
plasmawindowed
can be used if the widget is installed to:~/.local/share/plasma/plasmoids
It will remember any changes you make to the config as this is the same command used for "Windowed widgets" like the "Calculator" app. It has limited features for displaying the widget, but the command should be preinstalled.plasmoidviewer
, explained further down, can display a widget as a desktop widget, or a panel widget. You can also test a widget that is not yet installed. You will need to first install theplasma-sdk
package to use it.Install the widget and add it to your panel. Restarting plasma every time using:
plasmashell --replace
I only recommend this testing method for a final test as it takes a few seconds for the panel to load.
Run the following to test the Application Launcher widget:
plasmoidviewer
If you haven't yet, install the plasma-sdk
package with sudo apt install plasma-sdk
.
You can test an installed widget by using its plugin id.
Or use it to run a widget in a specific folder. This is particularly useful for development as you can now skip the install step.
Test as Desktop Widget
Note that --location=desktop
is used for the desktop wallpaper, not desktop widgets. Desktop widgets use --location=floating
.
Test as Horizontal Panel Widget
If we set plasmoidviewer
's plasmoid.formFactor
to be horizontal
and plasmoid.location
to the topedge
or bottomedge
, we can test a widget focusing in the panel.
Testing DPI Scaling
By setting the QT_SCALE_FACTOR=2
environment variable we can double the DPI value from 96
to 192
just for the plasmoidviewer
window. This is great for testing if your code will support a HiDPI screen.
If you're testing a very high DPI, you'll probably find the default plasmoidviewer
window is too small to show the widget, so we'll set the size and position of the window. Note that the window will go maximized if you set a size larger than you screen has available.
Enable logging
By default in Qt 5.9, QML's console.log()
, which used to write a string to stdout (the terminal output), is hidden by default.
You can see console.log()
output with the following environment variable command:
However it is much easier to always have it shown for the current user, including in the system log (journalctl -b0 -f
). To do so, we need to set [Rules] qml.debug=true
in ~/.config/QtProject/qtlogging.ini
. You can easily set it by running this kwriteconfig5
command:
You should now see output when you add console.log()
statements to your widget. You can place them in any function like the Component.onCompleted
signal handler.
contents/ui/main.qml
Or in a onPropertyChanged
signal. The following example will print a log message when you click the button.
contents/ui/main.qml
Last updated