[Interest] Quick Controls 2: custom control

Jérôme Godbout jerome at bodycad.com
Thu Apr 13 15:15:57 CEST 2017


I would be curious, in QtQuick.Control 1.x you could do the following:

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Styles 1.1

Control
{
id: component
property int rotationbuttonWidth: 50
property bool pressed: false
property color borderHighlightColor: 'black'
property color pressColor: 'blue'
property color unpressColor: 'red'
// Style Can be a single Component into a singleton to create only once and
could hold the color for generic application color
style: Style
{
property Component panel:
Rectangle
{
readonly property var control: __control
implicitWidth: control.rotationbuttonWidth
implicitHeight: implicitWidth
radius: implicitWidth / 2
border.color: control.borderHighlightColor
border.width: 2
color: control.pressed ? control.pressColor : control.unpressColor
}
}
// add other control behavior here (MouseArea, current value, min, max...)
}

I also wonder what is the equivalent in QtQuick.Control 2.x ? Does it make
any sense at all, since the style is dropped ? Do we only have to build
them from scratch with Items and use some sort of style singleton to hold
the color, size and other application style parameters?

I would probably do a singleton with a loader that load my particular
settings that I could change on the fly.

[image: bodycad] <https://www.bodycad.com/>
Jerome Godbout
Software Developer
2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
T:  +1 418 527-1388
E: jerome at bodycad.com
www.bodycad.com

The contents of this email message and any attachments are intended solely
for the addressee(s) and may contain confidential and/or privileged
information and may be legally protected from disclosure. If you are not
the intended recipient of this message or their agent, or if this message
has been addressed to you in error, please immediately alert the sender by
reply email and then delete this message and any attachments. If you are
not the intended recipient, you are hereby notified that any use,
dissemination, copying, or storage of this message or its attachments is
strictly prohibited.

Le contenu de ce message et les pièces jointes sont destinés uniquement
pour le(s) destinataire(s) et peuvent contenir des informations
confidentielles et / ou privilégiées qui peuvent être protégées légalement
contre toute divulgation. Si vous n'êtes pas le destinataire de ce message
ou son agent, ou si ce message vous a été adressé par erreur, s’il vous
plaît avertir immédiatement l'expéditeur par courriel de réponse, puis
supprimer ce message et les pièces jointes. Si vous n'êtes pas le
destinataire prévu, vous êtes par la présente informé que toute
utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces
jointes est strictement interdit.

On Wed, Apr 12, 2017 at 9:12 AM, Alexander Dyagilev <alervdvcw at gmail.com>
wrote:

> Am I right that this is what I'm looking for?
>
> http://doc.qt.io/qt-5/qtqml-tutorials-extending-qml-example.html
>
>
>
> On 4/12/2017 4:09 PM, Alexander Dyagilev wrote:
>
>> Hello,
>>
>> I know about a possibility to customize existing controls.
>> (http://doc.qt.io/qt-5/qtquickcontrols2-customize.html)
>>
>> But what if I would like to create completely new one? Including ability
>> to draw it by myself.
>>
>> Is it possible with Quick Controls2?
>>
>> If yes, please give me a link to the docs from which I could start.
>>
>> I failed to find one....
>>
>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170413/59deb8f1/attachment.html>


More information about the Interest mailing list