Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:36:11+00:00 2026-05-28T04:36:11+00:00

A simple question, (hopefully with a simple answer). QTreeView will pass Qt.DisplayRole to the

  • 0

A simple question, (hopefully with a simple answer).

QTreeView will pass Qt.DisplayRole to the model’s data function when fetching rows for display, by default.
But say I wanted to pass ‘MyAwesomeTreeDisplayRole’ instead of Qt.DisplayRole, what would I need to do?
I can’t seem to find anything about where the view decides to use displayrole or how to override it.

Just before you ask why I want to do such awful things..

Basically, my QAbstractItemModel is intended to be usable both for a treeview (1 column) and a tableview (multiple columns, based on parent).
Using the same DisplayRole for both types of views doesn’t really work, since then I’m forced to return the same data for both. This results in me only seeing the first column in the treeview when I want to return a concatenation of a couple of columns.

I think the simplest way would be to just use custom roles (TreeDisplayRole and TableDisplayRole).

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:36:12+00:00Added an answer on May 28, 2026 at 4:36 am

    I don’t know, how to do it in python, but you have to create your own delegate to render items data. Delegate is actually the object, that requests any data from indices and renders it

    Note, that in common case QTreeView is able to show multiple columns, you should only have columnCount set incorrectly for top-level index

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, hopefully with a simple answer. I was under the impression I should
Hopefully a simple question although one I have found impossible to answer myself using
A small question hopefully with a simple answer, I am using jQuery draggable and
Hopefully this is a pretty simple question for someone to answer. I have a
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver
Hopefully this is a simple question to answer - I think I'm being a
Simple question, hopefully a simple answer: I'd like to do the following: private DateTime
New to git, so this is hopefully a simple question with a simple answer.
Hopefully a question with a very simple answer, but it's not one that I've
Hopefully there is a simple answer to this as it seems a simple question,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.