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. Use column as role in delegateChooser
Forum Updated to NodeBB v4.3 + New Features

Use column as role in delegateChooser

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

    Working in QML 5, I wish to format my table content (columns) differently based on the column number. For example, col 1 holds a string, col 2 holds a checkmark, col 3 holds and image. etc.

    I was hoping to use the column number in my delegatechooser but it fails (never matches a roleValue). Though if I print model.column in the delegate it does show my column number.

    How can I use column number in my chooser? (What's wrong with this code)

    DelegateChooser {
           id: chooser
           role: "model.column"
           DelegateChoice { roleValue: "0"; ItemDelegate { ... } }
           DelegateChoice { roleValue: "1"; SwitchDelegate { ... } }
           DelegateChoice { roleValue: "2"; SwipeDelegate { ... } }
       }
    
    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      I dunno what your model looks like, but have you tried it this way?

      DelegateChooser {
          DelegateChoice { column: 1; ItemDelegate { ... } }
          ...
      }
      

      You can also try 'display' as a role for DelegateChooser.

      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