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. QML ComboBox set Font
Forum Updated to NodeBB v4.3 + New Features

QML ComboBox set Font

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 7.8k 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.
  • N Offline
    N Offline
    nando76
    wrote on 11 Sept 2014, 08:37 last edited by
    #1

    Hi,

    i am very new to qml. Maybe somebody could help me please... :)

    Does somebody knows how to set a specific font to a comboBox im qml?

    I need this for the drop-down and for the lineedit (if the comboBox is editable).

    Greetings
    Nando

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 11 Sept 2014, 09:17 last edited by
      #2

      Hi,

      bq. I need this for the drop-down and for the lineedit (if the comboBox is editable).

      AFAIK this has not been provided yet.

      157

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 12 Sept 2014, 10:10 last edited by
        #3

        Did you check on style parameter ? Here one sample which I have.

        @ ComboBox {
        id : cBox4
        width: 100
        height: 40
        model : ["Banana","Apple","Lemon"]
        style: ComboBoxStyle {
        background: Rectangle{
        height: control.height
        width: control.width
        color : "blue"
        }
        label: Rectangle{
        height: 140
        width: 20
        color : "green"
        Text {
        text : control.editText
        font.pointSize: 25
        font.bold: true
        }
        }
        }
        }
        @

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 12 Sept 2014, 10:12 last edited by
          #4

          The OP needs this for the Drop-Down as far as i see it in the question.

          [quote author="Dheerendra" date="1410516619"]Did you check on style parameter ? Here one sample which I have.

          @ ComboBox {
          id : cBox4
          width: 100
          height: 40
          model : ["Banana","Apple","Lemon"]
          style: ComboBoxStyle {
          background: Rectangle{
          height: control.height
          width: control.width
          color : "blue"
          }
          label: Rectangle{
          height: 140
          width: 20
          color : "green"
          Text {
          text : control.editText
          font.pointSize: 25
          font.bold: true
          }
          }
          }
          }
          @[/quote]

          157

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dheerendra
            Qt Champions 2022
            wrote on 12 Sept 2014, 12:05 last edited by
            #5

            Thanks you P3C0 for pointing out this. Question also said lineEdit. Some tweak may lead up the font of drop down as well.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qwasder85
              wrote on 28 Jan 2016, 08:47 last edited by
              #6

              Hi, I'm a bit late to the party, but this might help others in the future.
              You probably already found this post concerning the style of the ComboBox's dropdown: https://forum.qt.io/topic/32611/how-to-customize-combobox-from-qtquick-controls

              If you have an editable ComboBox, you can change the appearence of the LineEdit component by changing the content of the internal __editor Component:

              __editor: Item {
                  implicitWidth:  100
                  implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
                  clip:           true
              
                  Rectangle {
                      anchors { fill: parent; bottomMargin: 0 }
                      color:  "#44ffffff"
                      radius: baserect.radius
                  }
              
                  Rectangle {
                      id: baserect
              
                      anchors     { rightMargin: -radius; bottomMargin: 1 }
                      gradient: Gradient {
                          GradientStop { color: "#e0e0e0" ; position: 0 }
                          GradientStop { color: "#fff" ; position: 0.1 }
                          GradientStop { color: "#fff" ; position: 1 }
                      }
                      radius: TextSingleton.implicitHeight * 0.16
                      anchors.fill: parent
                      border.color: control.activeFocus ? "#47b" : "#999"
                  }
                  Rectangle {
                      color: "#aaa"
                      anchors.bottomMargin: 2
                      anchors.topMargin: 1
                      anchors.right: parent.right
                      anchors.top: parent.top
                      anchors.bottom: parent.bottom
                      width: 1
                  }
              }
              
              1 Reply Last reply
              0

              • Login

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