Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:38:04+00:00 2026-06-12T22:38:04+00:00

How to get different items containers in drop-down feature in QML as shown in

  • 0

How to get different items containers in drop-down feature in QML as shown in figure.

enter image description here

I tried the requirement in below implementation using listview but could not get the same. Below is the snippet

import QtQuick 1.1

Rectangle {
    width:400;
    height: 400;

    Rectangle {
            id:comboBox
            property variant items: ["Item 1", "Item 2", "Item 3"]

            signal comboClicked;
            width: 400;
            height: 30;
            z: 100;
            smooth:true;

            Rectangle {
                id:chosenItem
                radius:4;
                width:parent.width;
                height:comboBox.height;
                color: "#203586"
                smooth:true;
                Text {
                    anchors.top: parent.top;
                    anchors.margins: 8;
                    id:chosenItemText
                    x: 11
                    y: 5
                    color: "#ffffff"
                    text:"Menu";
                    anchors.topMargin: 5
                    anchors.left: parent.left
                    anchors.leftMargin: 12
                    font.family: "Arial"
                    font.pointSize: 14;
                    smooth:true
                }

                MouseArea {
                    width: 400
                    height: 30
                    anchors.bottomMargin: 0
                    anchors.fill: parent;
                    onClicked: {
                        comboBox.state = comboBox.state==="dropDown"?"":"dropDown"
                    }
                }
            }

            Rectangle {
                id:dropDown
                width:comboBox.width/4;
                height:0;
                clip:true;
                radius:4;
                anchors.top: chosenItem.bottom;
                anchors.margins: 2;
                color: "lightblue"

                ListView {
                    id:listView
                    height:500;
                    model: comboBox.items
                    currentIndex: 0
                    delegate: Item{
                        width:comboBox.width;
                        height: comboBox.height;


                        Text {
                            text: modelData
                            anchors.top: parent.top;
                            anchors.left: parent.left;
                            anchors.margins: 5;

                        }
                        MouseArea {
                            anchors.fill: parent;
                            onClicked: {
                                comboBox.state = ""
                            }
                        }
                    }
                }
            }


            states: State {
                name: "dropDown";
                PropertyChanges { target: dropDown; height:30*comboBox.items.length }
            }

            transitions: Transition {
                NumberAnimation { target: dropDown; properties: "height"; easing.type: Easing.OutExpo; duration: 1000 }
            }
        }
    }

With above approach am getting the drop-down as shown in below, which is not according to the requirement.

I tried with various approaches but I was not able to achieve the exact requirement with proper working
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:38:05+00:00Added an answer on June 12, 2026 at 10:38 pm

    Add a Rectangle to the delegate of the list view. Make the size of that Rectangle to be size of the item (comboBox.width, comboBox.height) minus what ever margin you like and add a radius to that rectangle this should produce the list shown in the first image.

    delegate: Item{
      width:comboBox.width;
      height: comboBox.height;
    
      Rectangle {
        width: parent.width - margin;
        height: parent.height - margin;
        anchors.centerIn: parent;
    
        Text {
          text: modelData
          anchors.top: parent.top;
          anchors.left: parent.left;
          anchors.margins: 5;
        }
        MouseArea {
          anchors.fill: parent;
          onClicked: {
            comboBox.state = ""
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to get different MIMI types when using finfo_open(FILEINFO_MIME_TYPE). For instance, based on
How to get current time of different countries in C# by using following any
I get different output when mocking a class once and when mocking a class
Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$
I want to be able to get different array values in my ajax callback
I think that handlers in android are tools to get different objects that are
I am working on MotionEvent by which i can get different - different gesture
Why do I get 2 different values for (apply (first '(+ 1 2)) (rest
I'm wondering whether I will ever get a different result when producing a checksum
I have code in javascript which get keycodes of different keys and set it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.