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. QTransposeproxymodel rewrite?
Forum Updated to NodeBB v4.3 + New Features

QTransposeproxymodel rewrite?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtransposeproxy
4 Posts 3 Posters 214 Views
  • 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.
  • F Offline
    F Offline
    firen
    wrote on last edited by
    #1

    Hi everyone,

    I have two views (where always only one is visible).

    1. First view uses a derived version of QAbstractTableModel (with many individual stuff for inserts and so on)
    2. The second view uses the same model, but with QTransposeProxyModel between ist:
      m_modelTransposed = new QTransposeProxyModel(this);
      m_modelTransposed->setSourceModel(m_model);
    

    In this situation m_modelTransposed doesn´t know the individual stuff I wrote for the model of the "first view", because setSourceModel gets a pointer of QAbstractItemModel, (called Upcast, right?)

    Maybe its now a little bit late, but what would be the best approach, that I can use the individual stuff from the model of 1. in the view of 2. but with the functionalitiy of QTransposeProxyModel as well?

    Do I have to rewrite QTransposeProxyModel completly?

    Some ideas or hints would be enough :-)

    Thank you!

    JonBJ VRoninV 2 Replies Last reply
    0
    • F firen

      Hi everyone,

      I have two views (where always only one is visible).

      1. First view uses a derived version of QAbstractTableModel (with many individual stuff for inserts and so on)
      2. The second view uses the same model, but with QTransposeProxyModel between ist:
        m_modelTransposed = new QTransposeProxyModel(this);
        m_modelTransposed->setSourceModel(m_model);
      

      In this situation m_modelTransposed doesn´t know the individual stuff I wrote for the model of the "first view", because setSourceModel gets a pointer of QAbstractItemModel, (called Upcast, right?)

      Maybe its now a little bit late, but what would be the best approach, that I can use the individual stuff from the model of 1. in the view of 2. but with the functionalitiy of QTransposeProxyModel as well?

      Do I have to rewrite QTransposeProxyModel completly?

      Some ideas or hints would be enough :-)

      Thank you!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @firen said in QTransposeproxymodel rewrite?:

      In this situation m_modelTransposed doesn´t know the individual stuff I wrote for the model of the "first view", because setSourceModel gets a pointer of QAbstractItemModel, (called Upcast, right?)

      If I understand your question correctly. This is where you can use C++ dynamic_cast<> (or Qt qobject_cast<>) for somewhere to determine what derived type a QAbstractTableModel actually is.

      MyDerivedModel *myDerivedModel= dynamic_cast<MyDerivedModel *>(m_modelTransposed->sourceModel());
      if (myDerivedModel)
      {
          // it's a `MyDerivedModel`
          myDerivedModel->someMethodOfMyDerivedModel();   // :)
      }
      

      P.S.
      If I have misunderstood and you have m_modelTransposed points to QTransposeProxyModel points to SomeModelOfYours, and you want m_modelTransposed to be able to get at SomeModelOfYours, then you can go via

      QTransposeProxyModel *proxyModel = dynamic_cast<QTransposeProxyModel *>(m_modelTransposed->sourceModel());
      if (proxyModel)
      {
          MyModel *myModel = dynamic_cast<MyModel  *>(proxyModel->sourceModel());
          if (myModel) ...
      }
      

      I get confused as to which situation you are asking about :) But one of the above should help?

      1 Reply Last reply
      1
      • F firen

        Hi everyone,

        I have two views (where always only one is visible).

        1. First view uses a derived version of QAbstractTableModel (with many individual stuff for inserts and so on)
        2. The second view uses the same model, but with QTransposeProxyModel between ist:
          m_modelTransposed = new QTransposeProxyModel(this);
          m_modelTransposed->setSourceModel(m_model);
        

        In this situation m_modelTransposed doesn´t know the individual stuff I wrote for the model of the "first view", because setSourceModel gets a pointer of QAbstractItemModel, (called Upcast, right?)

        Maybe its now a little bit late, but what would be the best approach, that I can use the individual stuff from the model of 1. in the view of 2. but with the functionalitiy of QTransposeProxyModel as well?

        Do I have to rewrite QTransposeProxyModel completly?

        Some ideas or hints would be enough :-)

        Thank you!

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @firen said in QTransposeproxymodel rewrite?:

        I can use the individual stuff from the model of 1. in the view of 2. but with the functionalitiy of QTransposeProxyModel as well?

        What is "stuff from the model of 1"? data should be managed automatically

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • F Offline
          F Offline
          firen
          wrote on last edited by firen
          #4

          Thanks guys so far!

          Maybe I am in less trouble than I thought (see @VRonin s comment) I am not 100% sure to be honest. I am going to implement a new Dialog where I will realy need the transposed view.
          Maybe then it is easier to understand for me what the problem is or if there is no real problem... :-)

          I leave this ticket open if thats ok

          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