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] How can I change the font size and Co in a TableView?
Qt 6.11 is out! See what's new in the release blog

[QML] How can I change the font size and Co in a TableView?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 2.9k 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.
  • R Offline
    R Offline
    rylicx
    wrote on last edited by
    #1

    Hey~
    I am trying to change the font size of the values in the TableView.
    But it doesn't work...

    This is my code which I am using:

    import QtQuick 2.0
    import QtQuick.Controls 1.4
    import QtQuick.Window 2.1
    
    Window {
        id: participantWindow
        width: 840
        height: 500
    
        TableView {
            anchors.fill: racesWindow
            width: 840
            height: 400
            model: getData
    
            TableViewColumn {
                role: "name"
                title: "Name"
                width: 200
            }
        }
        Button{
            id: close
            width: 840
            height: 80
            anchors.horizontalCenter: racesWindow
            text: "Save"
            MouseArea{
                onClicked: racesWindow.close()
            }
        }
    }
    

    How can I fix that? Any ideas?
    I would be so happy if anybody could help me~
    Thank you so much!!!!

    1 Reply Last reply
    0
    • CKurduC Offline
      CKurduC Offline
      CKurdu
      wrote on last edited by CKurdu
      #2

      Hi rylics,
      You can use itemDelegate in TableView for specific cells or all cells.

      Window {
          id: participantWindow
          width: 840
          height: 500
      
          TableView {
              anchors.fill: racesWindow
              width: 840
              height: 400
              model: getData
      
              TableViewColumn {
                  role: "name"
                  title: "Name"
                  width: 200
              }
              itemDelegate: Item {
                              Text {
                                anchors.verticalCenter: parent.verticalCenter
                                color: "green"
                                elide: styleData.elideMode
                                text: styleData.value
                                font.pixelSize: 14
                              }
                       }
          }
          Button{
              id: close
              width: 840
              height: 80
              anchors.horizontalCenter: racesWindow
              text: "Save"
              MouseArea{
                  onClicked: racesWindow.close()
              }
          }
      }
      
      

      You reap what you sow it

      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