Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Itemview

Itemview

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 3.3k 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.
  • I Offline
    I Offline
    Immii
    wrote on last edited by
    #1

    Is there any way I can have different tableview header for two different view from same model.
    I want for one view my header should be a b c but for other i want my header should be x y z. I dont know how to use custom role in Model::headerData(), can any one please give me some clue,
    code would be great help

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      I do that by inserting a custom proxy model between the view and the model (e.g. QSortFilterProxyModel subclass if you want its features anyway) and providing the headers there.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Immii
        wrote on last edited by
        #3

        Yes we talked about that but due to some reason I have been told not to use proxy thing due to some performance hit because proxy does maping and since model is big it hits the performance.
        Could there be any other way around?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          QSortFilterProxyModel has a performance hit due to some internal duplication for mapping, but the generic QAbstractProxyModel can be taylored to not duplicate any data.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            Immii
            wrote on last edited by
            #5

            DerManu: what you are saying might be quite possible, but what I am thinking here is headerData() has one parameter role, I am kind of wondering how can i set custom role so that for one custom role it should return me one set of value and for other it should return other set of value.
            I am not sure but I think if I am able to set this role thing I might have my solution, what do you experts say?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Just use QIdentityProxyModel as your base class for your proxy then. It's mapping is trivial, so there is only a minimal performance penalty.

              1 Reply Last reply
              0
              • I Offline
                I Offline
                Immii
                wrote on last edited by
                #7

                Andre: Okay but without using proxy could there be any way to have different header for two different view from same model?
                I see a role paramenter in headerData() but I coiuld not find any way to set that looks like I am missing something, can you guys help?

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  Immii
                  wrote on last edited by
                  #8

                  I am wondering how can i use Qt::userRole here.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    [quote author="Immii" date="1341867904"]I am wondering how can i use Qt::userRole here.[/quote]

                    Not at all.

                    Why do you make it so difficult for yourself? The proxy method really is the simplest route.

                    An alternative could be to "just" create your own QHeaderView subclasses and render the headers yourself without using the model at all, but it is a much more complex route than using a trivial proxy model. And no, trying to use a delegate on the header is not going to work either.

                    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