How to create DropShadow effect in QML with Qt6? - qt

In Qt5 this was easy with using DropShadow.
But in Qt6 the module QtGraphicalEffects is removed.
Is there any trick, workaround or maybe new way in Qt6 to create drop shadow around some component?

As you noticed yourself, Qt Graphical Effects is removed (definitely):
The following modules are removed and not planned to be developed
further.
Qt Graphical Effects
[...]
However, the Qt Graphical Effects is made compatible with the new QRhi (Qt Rendering Hardware Interface) used by Qt6. [1]
Note that this doesn't mean it will be included in Qt 6 at a later stage. [2]
Nevertheless, I expect it would be relatively easy to use DropShadow from the dev or Qt 5.15 branch of git.
Note that it will be included as a Qt5 Compatibility API in Qt6.1. (Final release of Qt 6.1 is originally planned for 27.04.2021 [3])

Qt6 DropShadow
import Qt5Compat.GraphicalEffects
DropShadow {}

You can add QtGraphicalEffects module to Qt6 manually and then use DropShadow in your code.
Generally, to unofficially employ QtGraphicalEffects in Qt 6, do the following:
$ git clone git://code.qt.io/qt/qtgraphicaleffects.git
$ cd qtgraphicaleffects/
$ git checkout 59ab3e11433a5157aac0f3af7c0d7fe70a373373 & cd ..
$ ~/Qt/<VERSION>/gcc_64/bin/qmake qtgraphicaleffects
$ make
$ find qtgraphicaleffects/src/effects/ -maxdepth 1 -name \*.qml -exec cp {} qml/QtGraphicalEffects \;
$ cp -r qtgraphicaleffects/src/effects/private/ qml/QtGraphicalEffects
$ cp -r qml/QtGraphicalEffects ~/Qt/<VERSION>/gcc_64/qml/
This will obtain the module source code to the point where it wasn't yet completely removed from the repository. Then it is built and copied with the required files to the Qt installed directory.
So to use DropShadow component, add
import QtGraphicalEffects 1.0
You can also use the following components in your QML code:
BrightnessContrast
Colorize
ColorOverlay
ConicalGradient
Desaturate
Displace
DropShadow
FastBlur
FastGlow
GammaAdjust
Glow
HueSaturation
LevelAdjust
LinearGradient
OpacityMask
RadialGradient
RectangularGlow
ThresholdMask

Related

Yocto: remove packageconfig item

In a recipe (meta-qt5/recipes-qt/qt5/qttools_git.bb) I found:
PACKAGECONFIG ??= ""
PACKAGECONFIG[qtwebkit] = ",,qtwebkit"
now, under my own meta-custom-layer I'm going to create the same path and add a .bbappend file: meta-custom-layer/meta-qt5/recipes-qt/qt5/qttools_git.bbappend.
I want to remove the second line, because I'm not interested in qtwebkit.
It would be enough to put:
PACKAGECONFIG[qtwebkit] = ""
or I need something else?
Because there is the ??= operator, I guess the PACKAGECONFIG variable is updated with qtwebkit elsewhere. I need to find and remove also that assignement? Is there a quick way to find out where is appended?
UPDATE
To find where the qtwebkit is configured I tried to use grep:
$ grep -nrw . -e qtwebkit
./layers/meta-st/meta-st-openstlinux/recipes-samples/packagegroups/packagegroup-framework-sample-qt-extra.bb:30: qtwebkit \
./layers/meta-st/meta-st-openstlinux/recipes-samples/packagegroups/packagegroup-framework-sample-qt-extra.bb:53: qtwebkit-examples \
Binary file ./layers/meta-qt5/.git/index matches
./layers/meta-qt5/README.md:8:When building stuff like `qtdeclarative`, `qtquick`, `qtwebkit`, make
./layers/meta-qt5/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb:12: ${#bb.utils.contains('DISTRO_FEATURES', 'opengl', 'qtwebkit-dev', '', d)} \
./layers/meta-qt5/recipes-qt/qt5/qttools/0001-add-noqtwebkit-configuration.patch:25: BROWSER = qtwebkit
./layers/meta-qt5/recipes-qt/qt5/qttools/0001-add-noqtwebkit-configuration.patch:32:-equals(BROWSER, "qtwebkit") {
./layers/meta-qt5/recipes-qt/qt5/qttools/0001-add-noqtwebkit-configuration.patch:33:+equals(BROWSER, "qtwebkit"):!contains(CONFIG, noqtwebkit) {
./layers/meta-qt5/recipes-qt/qt5/qttools_git.bb:28:PACKAGECONFIG[qtwebkit] = ",,qtwebkit"
./layers/meta-qt5/recipes-qt/qt5/qttools_git.bb:32: ${#bb.utils.contains('PACKAGECONFIG', 'qtwebkit', '', 'CONFIG+=noqtwebkit', d)} \
./layers/meta-qt5/recipes-qt/qt5/qt5-creator_git.bb:17:DEPENDS = "qtbase qtscript qtwebkit qtxmlpatterns qtx11extras qtdeclarative qttools qttools-native qtsvg chrpath-replacement-native"
./layers/meta-qt5/recipes-qt/qt5/qtbase_git.bb:76:# This is in qt5.inc, because qtwebkit-examples are using it to enable ca-certificates dependency
./layers/meta-qt5/recipes-qt/qt5/qtwebkit-examples_git.bb:18:DEPENDS += "qtwebkit qtxmlpatterns"
./layers/meta-qt5/recipes-qt/qt5/qtwebkit-examples_git.bb:19:RDEPENDS_${PN}-examples += "qtwebkit-qmlplugins"
./layers/meta-qt5/recipes-qt/qt5/qtwebkit_git.bb:12:# Patches from https://github.com/meta-qt5/qtwebkit/commits/b5.11
./layers/meta-qt5/lib/recipetool/create_qt5.py:101: 'webkit': 'qtwebkit',
./layers/meta-qt5/lib/recipetool/create_qt5.py:102: 'webkitwidgets': 'qtwebkit',
So I think the line to remove is the one I described above.
bitbake -e <image> leads to an output so long that overflows the console buffer... I tried to grep the output looking for qtwebkit but nothing is returned.
The same applies for grep -nrw . -e DISTRO_FEATURES | grep qtwebkit.
The PACKAGECONFIG[qtwebkit] = ",,qtwebkit" line is showing what enabling or disabling that feature would do if qtwebkit exists in that package's PACKAGECONFIG variable (see here). Based on that second line and the documentation, it's doing "nothing" in either case.
More towards your question about how to diagnose something like, "why is this variable set," a starting point is to use bitbake -e [optional package or image name] > env.log to dump the environment to a log file that you can review. It would be worth checking this with no package or image name as well as with the package and whatever image you're trying to build (sometimes the image configuration might enable a feature in another package's PACKAGECONFIG via other variables; checking the environment will often show you why something was set).

This application failed to start because it could not find or load the Qt platform plugin “cocoa”

I followed the following instruction to install PyQt5 for python2.7.
My system is Mac OS Al Captain. Qt5.5 library, PyQt5_gpl-5.7, sip-4.18.1 libraries are used.
mkdir pyqt
cd pyqt/
virtualenv qtenv
source qtenv/bin/activate
mkdir tmp
cp /Users/ge/Downloads/PyQt-gpl-5.4.1.tar.gz ./tmp
cp /Users/ge/Downloads/sip-4.16.7.tar.gz ./tmp
cd tmp/
tar xvf sip-4.16.7.tar.gz
tar xvf PyQt-gpl-5.4.1.tar.gz
cd sip-4.16.7
python configure.py -d /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --arch x86_64
make
sudo make install
sudo make clean
cd ../PyQt-gpl-5.4.1
python configure.py --destdir /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --qmake /Applications/Qt/5.4/clang_64/bin/qmake
make
sudo make install
sudo make clean
However, It generates error as below and refuses to start the application codes as below:
from PyQt5 import QtGui # (the example applies equally well to PySide)
import pyqtgraph as pg
## Always start by initializing Qt (only once per application)
app = QtGui.QApplication([])
## Define a top-level widget to hold everything
w = QtGui.QWidget()
## Create some widgets to be placed inside
btn = QtGui.QPushButton('press me')
text = QtGui.QLineEdit('enter text')
listw = QtGui.QListWidget()
plot = pg.PlotWidget()
## Create a grid layout to manage the widgets size and position
layout = QtGui.QGridLayout()
w.setLayout(layout)
## Add widgets to the layout in their proper positions
layout.addWidget(btn, 0, 0) # button goes in upper-left
layout.addWidget(text, 1, 0) # text edit goes in middle-left
layout.addWidget(listw, 2, 0) # list widget goes in bottom-left
layout.addWidget(plot, 0, 1, 3, 1) # plot goes on right side, spanning 3 rows
## Display the widget as a new window
w.show()
## Start the Qt event loop
app.exec_()
The errors generated are:
This application failed to start because it could not find or load the Qt platform plugin “cocoa”
Then I searched with google, a temporary solution is to add an env path to the system called:
QT_QPA_PLATFORM_PLUGIN_PATH = {QT_SRC}/plugins
I would like to know if there is any way to set it up when I install pyqt5 instead of setting this path to my system after installation. It should be some configure.py options, right?

Qt Creator Unit Test Project

In Qt Creator, when I create a new Unit Test project it will not build successfully if the full path to the project contains a space.
I've tracked the bug down to the makefile produced by qmake. The makefile contains a line near the top like:
DEFINES = -DUNICODE -DWIN32 -DSRCDIR=\"C:/Users/Smith/Qt Projects/Unit_Tests/\" -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR=\"C:/Users/Smith/Qt Projects/Debug_Unit_Tests\"
The quotes in the values for SRCDIR and QT_TESTCASE_BUILDDIR are escaped with backslashes. If I delete the backslashes from Makefile.Debug, then the project will build successfully.
Obviously, I don't want to have manually delete the backslashes every time. I'd also like to avoid a custom build step that removes the backslashes. Because qmake has so many options, I was hoping there was something I could just put in the .pro file that will fix this.
I tried something like DEFINES -= QT_TESTCASE_BUILDDIR. That doesn't work however because QT_TESTCASE_BUILDDIR is not yet defined. testlib apparently adds its own definitions later.
I am using:
Visual Studio 2010 SP 1
Qt 5.0.2
Qt Creator 2.7.0
Windows 7
What's the simplest way to get rid of the backslashes?
Edit: This also happens OSX.
The definitions added by testlib are in testlib_defines.prf which is in:
C:\Qt\Qt5.0.2\5.0.2\msvc2010\mkspecs\features
Change...
DEFINES += QT_TESTCASE_BUILDDIR=\\\"$$OUT_PWD\\\"
...to...
DEFINES += QT_TESTCASE_BUILDDIR=\"$$OUT_PWD\"
The other part is easy. The extra backslashes for SRCDIR come from the .pro file itself. Change...
DEFINES += SRCDIR=\\\"$$PWD/\\\"
...to...
DEFINES += SRCDIR=\"$$PWD/\"
Every time you install a new version of Qt, you'll have to edit the .prf file but that's better than having to edit the makefile every time qmake runs.

How do I get a list of the classes compiled into my Flex app? [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Determining linkage dependencies in Flex applications
I have several Flex applications in a project, and I would like to know if there's a way to get a list of the classes (and ideally, other assets) that are being compiled into each one. I want an easy way of making sure I've kept things separate and there aren't unnecessary dependencies. Any ideas? I'm running Flash Builder 4.
What about a grep through the imports?
$ grep -R 'import ' src/ | awk '{ print $2 }' | sort -u
flash.events.ContextMenuEvent;
flash.events.Event;
...
$
Change the swf file extension to zip, incompressible and look at the manifest?

Is there any way to find unreferenced code in Flex Builder?

We've got several Flex projects, one of which has just been refactored. I'm wondering if there's an easy way to tell which classes and functions (if any) aren't being used any more?
I've discovered that we've definitely got some unused code, because running ASDoc on the entire project reports some compilation errors which don't get reported by Flex Builder (implying that those classes aren't being used any more). I'm hoping to find a more robust and complete method, and preferably one which can work at function level too.
My ugly hack:
Using the swfdump tool from SWFtools, dump the disassembly from (all of) your swf(s):
swfdump -a my.swf > dump
Get a list of all your classes:
find . -name "*.as" -exec basename {} .as \; > classes
find . -name "*.mxml" -exec basename {} .mxml \; >> classes
Apply one list to the other:
for class in $(<classes) ; do grep -q \\\<$class\\\> dump || echo $class ; done
I am doing this on Windows, using Cygwin.
Check out the Flex PMD tool. It was recently released in beta, but we've been using it at work for a few weeks, and it seems to work pretty nicely.
Note, the swfdump tool included with the Flex SDK will work in place of the SWFTools version in the bash script listed above.
This doesn't really answer your question but you can find the references to a single class, variable or function by selecting it (in code editor) and pushing: Ctrl+Shift+G . I think that's what you can get out of Flex / Flash Builder at the moment.

Resources