[Interest] Issue with ComboBox style properties in QtQuick.Controls 2.1

Nibedit Dey nibedit.dev at gmail.com
Thu May 18 16:11:11 CEST 2017


Hello Everyone,

I am trying to use SwipeView and ComboBoxStyle together in a file.
In QtQuick.Controls 2.1, seems like style properties is not there.

I tried to mix both modules. I believe we shouldn't do this.
But when I experimented this approach to use SwipeView and ComboboxStyle
together.
Please refer to the snippets below.

In first case, QtQuick.Controls 2.1 is used before 1.4. Hence it works
properly.
In second case, QtQuick.Controls 1.4 is used before 2.1 and it gives error.
In third case, I mixed and accessed with another name and it fails again.

Is it a bug in ComboBox implementation in QtQuick.Controls 2.1? How can I
use both SwipeView and ComboBoxStyle together?

Snippet 1: //Works

import QtQuick 2.5

import QtQuick.Window 2.2

import QtQuick.Controls 2.1

import QtQuick.Controls 1.4

import QtQuick.Controls.Styles 1.4


Window {

    visible: true

    width: 640

    height: 480

    title: qsTr("Snippet 1")


    SwipeView{

        currentIndex: 0

        anchors.fill : parent


        Item {

            id: page1

            ComboBox {

                x: 100

                width: 200

                model: [ "Apple","Banana", "Orange","Others" ]


                style: ComboBoxStyle {

                    id: comboBox

                    background: Rectangle {

                        id: rectCategory

                        color: "transparent"

                        border.width: 1

                        border.color: "gray"

                        radius: 15

                    }

                    label: Text {

                        verticalAlignment: Text.AlignVCenter

                        horizontalAlignment: Text.AlignHCenter

                        font.pixelSize: 20

                        font.capitalization: Font.SmallCaps

                        color: "#40C0FF"

                        text: control.currentText

                    }

                }

            }

        }

        Item {

            id:page2

        }

    }

}



Snippet 2:


Cannot assign to non-existent property "style"


import QtQuick 2.5

import QtQuick.Window 2.2

import QtQuick.Controls 1.4

import QtQuick.Controls.Styles 1.4

import QtQuick.Controls 2.1

Window {

    visible: true

    width: 640

    height: 480

    title: qsTr("Snippet 2")


    SwipeView{

        currentIndex: 0

        anchors.fill : parent

        Item {

            id: page1

            ComboBox {

                x: 100

                width: 200

                model: [ "Apple","Banana", "Orange","Others" ]

                style: ComboBoxStyle {

                    id: comboBox

                    background: Rectangle {

                        id: rectCategory

                        color: "transparent"

                        border.width: 1

                        border.color: "gray"

                        radius: 15

                    }

                    label: Text {

                        verticalAlignment: Text.AlignVCenter

                        horizontalAlignment: Text.AlignHCenter

                        font.pixelSize: 20

                        font.capitalization: Font.SmallCaps

                        color: "#40C0FF"

                        text: control.currentText

                    }

                }

            }

        }

        Item {

            id:page2

        }

    }

}

Snippet 3:

Error: NewControls.SwipeView is not a type


import QtQuick 2.5

import QtQuick.Window 2.2

import QtQuick.Controls 2.1 as OldControls

import QtQuick.Controls 1.4 as NewControls

import QtQuick.Controls.Styles 1.4


Window {

    visible: true

    width: 640

    height: 480

    title: qsTr("Snippet 3")

    NewControls.SwipeView{

        currentIndex: 0

        anchors.fill : parent

        Item {

            id: page1

            OldControls.ComboBox {

                x: 100

                width: 200

                model: [ "Apple","Banana", "Orange","Others" ]

                style: ComboBoxStyle {

                    id: comboBox

                    background: Rectangle {

                        id: rectCategory

                        color: "transparent"

                        border.width: 1

                        border.color: "gray"

                        radius: 15

                    }

                    label: Text {

                        verticalAlignment: Text.AlignVCenter

                        horizontalAlignment: Text.AlignHCenter

                        font.pixelSize: 20

                        font.capitalization: Font.SmallCaps

                        color: "#40C0FF"

                        text: control.currentText

                    }

                }

            }

        }

        Item {

            id:page2

        }

    }

}


Let me know, your suggestions.


Regards,
Nibedit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170518/1143b643/attachment.html>


More information about the Interest mailing list