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. TableView and items [solved]

TableView and items [solved]

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • Z Offline
    Z Offline
    Zanis
    wrote on last edited by
    #1

    Hello,

    I wanted to know if it's possible to put something else than string or number into a TableView ? Like a checkbox or a ComboBox. I tried to search for examples but I can only fine ListView doing such things.

    I want a TableView to have a header and to sort the elements. It's like this :

    Player Name (String) - Connection Status (image) - Kick Player (Button)

    I tried also to create a rowDelegate with my differents items embedded in a Row, but it doesn't work either.

    Someone alreay tried this or has an idea on how to do such thing ?

    Thanks in advance !

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      Like this perhaps?

      @
      import QtQuick 2.1
      import QtQuick.Controls 1.0

      Rectangle {
      id: root
      width: 600
      height: 400
      TableView {
      model: ListModel {
      id: largeModel
      Component.onCompleted: {
      for (var i=0 ; i< 50 ; ++i)
      largeModel.append({"name":"Person "+i , "age": Math.round(Math.random()*100), "gender": Math.random()>0.5 ? "Male" : "Female"})
      }
      }
      anchors.fill: parent
      TableViewColumn {
      title: "Name"
      role: "name"
      }
      TableViewColumn {
      title: "status"
      role: "imagesource"
      width: 50
      delegate: Image {
      fillMode: Image.PreserveAspectFit
      source: "http://www.mricons.com/store/png/4092_1178_128_status_icon.png"
      }
      }
      TableViewColumn {
      title: ""
      delegate: Button {
      text: "Kick Player"
      onClicked: print("kicked player")
      }
      }
      }
      }
      @

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zanis
        wrote on last edited by
        #3

        Yeah that's it ! Ok I get it, i didn't think about putting the delegate directly into the TableViewColumn :) Thank for this !

        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