Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Design of combo box in a different manner as stated.

Design of combo box in a different manner as stated.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 392 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JasmineSethi
    wrote on last edited by
    #1

    Is it possible to design More than one combo box where combo box Code is same(can re-use the code) but list of elements(listView) are different. So can we define combo box code in one qml and use the same code where ever needed, only list of elements(listview) need to changed every where.
    How this can be achieved?
    eg: Combo Box 1-> Days: {Mon, Tues, Wed}
    Combo Box 2 -> Year: {Jan, Feb, Mar}

    I dont want to write the combo box code again and again. One code for combo box and multiple code for list view.

    ODБOïO 1 Reply Last reply
    0
    • J JasmineSethi

      Is it possible to design More than one combo box where combo box Code is same(can re-use the code) but list of elements(listView) are different. So can we define combo box code in one qml and use the same code where ever needed, only list of elements(listview) need to changed every where.
      How this can be achieved?
      eg: Combo Box 1-> Days: {Mon, Tues, Wed}
      Combo Box 2 -> Year: {Jan, Feb, Mar}

      I dont want to write the combo box code again and again. One code for combo box and multiple code for list view.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi,
      @JasmineSethi said in Design of combo box in a different manner as stated.:

      can re-use the code

      that is one of root concepts in QML and programming in general

      MyCombo.qml

      import QtQuick 2.0
      import QtQuick.Controls 2.4
      import QtQuick.Controls.Styles 1.4
      
      ComboBox {
       background: Rectangle{
          color: "lightblue"
       }
       width: 100
      }
      
      

      main.qml

      import QtQuick 2.12
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.4
      
      Window {
          visible: true
          width: 640
          height: 480
          Row{
              MyCombo{
                  model: ["Mon","Tues","Wed"]
      
              }
              MyCombo{
                  model: ["Jan","Meb","Mar"]
              }
          }
      }
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved