Forums

OverviewFelgo 2 Support (Qt 5) › QtQuick.Controls 2.5

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23448

    Gabor

    Hi,

    I have a very simple page:

    import QtQuick 2.0
    import Felgo 3.0
    import QtQuick.Controls 2.5
    
    Page {
        title: "Add Medications"
    
        Rectangle {
                   id: backgrnd
                   anchors.fill: parent
                   color: "lightgreen"
    
                   Text {
                       id: name
                       text: "Patient:"
                       x: 30
                       y: 20
                       font.bold: true
                       font.pointSize: 18
                       focus: false
                       color: "darkblue"
                   }
    
                   ComboBox {
                       id: patientCombo
                       width: dp(60)
                       height: dp(35)
                       anchors.bottom: name.bottom
                       anchors.left: name.right
                       anchors.leftMargin: dp(15)
                   }
               }
    }
    

    When I run it nothing is displayed. When I comment out QtQuick.Controls 2.5 (and ComboBox)  it works OK. Please help me to find out why is this happening.

    Thank you.

    #23449

    jrrobles79

    The QtQuickControls have some elements (as I understand) that can have some conflicts with QtQuick, you have to import the QtQuickControls first and add an alias like this:

     

    import QtQuick.Controls 2.5 as QQC25

    import Felgo 3.0

    import QtQuick 2.0

    ..

    ..

    QQC25.Combobox{

    }

    #23467

    Gabor

    Thank you jrrobles79.

    I changed the code as follows:

    import QtQuick.Controls 2.4 as QQC24
    import QtQuick.Controls 1.4 as QQC14
    import Felgo 3.0
    import QtQuick 2.0
    
    QQC14.ComboBox {
                id: medDosageCombo
                width: backgrnd.width / 10
                height: dp(25)
                anchors.bottom: medDosage.bottom
                anchors.left: medDosage.right
                anchors.leftMargin: dp(15)
                editable: false
                focus: true
    
                QQC24.delegate: QQC24.ItemDelegate {
                    text: index + 5
                }
    
                QQC24.displayText: currentIndex + 1
            }
    }

    Unfortunately when I do it this way it generates another error message: Expected type name on lines

    QQC24.delegate: QQC24.ItemDelegate and

    QQC24.displayText: currentIndex + 1.

    Is there any other reasons this may be happening?

     

     

    #23468

    jrrobles79

    Why are you using two versions of the same library? first you are using the combobox with the 1.4 version that is a lower version for the 2.4 properties you are trying to use, I use the alias only for the components not his properties or methods:

     

    import QtQuick.Controls 2.4 as QQC24
    
    import Felgo 3.0
    import QtQuick 2.0
    
    QQC24.ComboBox {
                id: medDosageCombo
                width: backgrnd.width / 10
                height: dp(25)
                anchors.bottom: medDosage.bottom
                anchors.left: medDosage.right
                anchors.leftMargin: dp(15)
                editable: false
                focus: true
    
                delegate: QQC24.ItemDelegate {
                    text: index + 5
                }
    
                displayText: currentIndex + 1
            }
    }

     

    Check the documentation for the combobox and itemdelegate

     

     

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support