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. How create the ComboBox with triangle on the right

How create the ComboBox with triangle on the right

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 3 Posters 771 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    How create the ComboBox with triangle on the right, using QtQuick.Controls 2.15?
    3.png

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      See the docs.

      (Z(:^

      M 1 Reply Last reply
      4
      • sierdzioS sierdzio

        See the docs.

        M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        @sierdzio this code draws in a file .qml, but how to draw in the .ui.qml file?

            ComboBox {
                id: control
                model: ["First", "Second", "Third"]
        
        
                indicator: Canvas {
                    id: canvas
                    x: control.width - width - control.rightPadding
                    y: control.topPadding + (control.availableHeight - height) / 2
                    width: 12
                    height: 8
                    contextType: "2d"
        
                    onPaint: {
                        context.reset();
                        context.moveTo(0, 0);
                        context.lineTo(width, 0);
                        context.lineTo(width / 2, height);
                        context.closePath();
                        context.fillStyle = control.pressed ? "#17a81a" : "#21be2b";
                        context.fill();
                    }
                }
            }
        
        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I know nothing about .ui.qml files, sorry. I never use them.

          (Z(:^

          J.HilkJ 1 Reply Last reply
          1
          • sierdzioS sierdzio

            I know nothing about .ui.qml files, sorry. I never use them.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @sierdzio said in How create the ComboBox with triangle on the right:

            I know nothing about .ui.qml files, sorry. I never use them.

            Right! These newfangled stuff no-one really needs 😁


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            sierdzioS 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @sierdzio said in How create the ComboBox with triangle on the right:

              I know nothing about .ui.qml files, sorry. I never use them.

              Right! These newfangled stuff no-one really needs 😁

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @J-Hilk said in How create the ComboBox with triangle on the right:

              @sierdzio said in How create the ComboBox with triangle on the right:

              I know nothing about .ui.qml files, sorry. I never use them.

              Right! These newfangled stuff no-one really needs 😁

              Very true. I've tried them out a couple of times, but really saw no point in using them. I hand-write all QML anyway. Perhaps I'm getting old and grumpy :D

              (Z(:^

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #7

                This way it works a bit, but how do I make the indicator background transparent?

                        indicator: Image{
                            z: 1
                            anchors.right: parent.right
                            anchors.verticalCenter: parent.verticalCenter
                            width: 15
                            height: width
                            fillMode: Image.PreserveAspectFit
                            source: "Images/triangle.png"
                
                        }
                
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mikeeeeee
                  wrote on last edited by
                  #8

                  it is work

                          indicator: Rectangle{
                              anchors.right: parent.right
                              height: parent.height
                              width: 15
                              color: "white"
                              Image{
                                  anchors.verticalCenter: parent.verticalCenter
                                  width: parent.width
                                  height: width
                                  fillMode: Image.PreserveAspectFit
                                  source: "Images/triangle.png"
                              }
                          }
                  
                  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