[Interest] QML Styled button and text issue
Nurmi J-P
jpnurmi at digia.com
Wed May 14 10:55:01 CEST 2014
On 14 May 2014, at 04:33, Jason H <scorp1us at yahoo.com> wrote:
> Text does not show up when used as:
>
>
> ///MyButton.QML
> import QtQuick 2.0
> import QtQuick.Controls 1.1
> import QtQuick.Controls.Styles 1.1
>
> Button {
> style: ButtonStyle {
> background: Rectangle {
> border.width: control.activeFocus ? 2 : 1
> border.color: "#888"
> radius: 10
> gradient: Gradient {
> GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
> GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
> }
> }
> label: Text{
> font.pixelSize: 30
> }
> }
>
> }
> }
>
>
>
> ///// Used as:
> MyButton {
> id: submit
> width: parent.width
> height: 90
> text: "Submit"
> }
> /////
>
> Does not show "Submit" Is there a way to define a Styled button component and just reassign the text?
It’s the label delegate of ButtonStyle that is responsible for rendering the text. Looks like you are creating a Text-element but not assigning the text:
ButtonStyle {
label: Text {
text: control.text // <---
}
}
--
J-P Nurmi
More information about the Interest
mailing list