Time for action – creating an item for drawing outlined text
The goal of the current exercise is to be able to make the following QML code work:
import QtQuick 2.3 import OutlineTextItem 1.0 Rectangle { width: 800; height: 400 OutlineTextItem { anchors.centerIn: parent text: "This is outlined text" fontFamily: "Arial" fontPixelSize: 64 color: "#33ff0000" antialiasing: true border { color: "blue" width: 2 style: Qt.DotLine } } }
And produce the following result:
Start with an empty Qt project with the core
, gui
, and quick
modules activated. Create a new class and call it OutlineTextItemBorder
. Delete the implementation file as we are going to put all code into the header file. Place the following code into the class definition:
class OutlineTextItemBorder : public QObject { Q_OBJECT Q_PROPERTY(int width MEMBER m_width NOTIFY widthChanged) Q_PROPERTY(QColor color MEMBER m_color NOTIFY...