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. Delegate access in view
Forum Updated to NodeBB v4.3 + New Features

Delegate access in view

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 698 Views 2 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.
  • O Offline
    O Offline
    OldCoder53
    wrote on last edited by
    #1

    Hi all,

    using model view architecture. Qt 5.9.3

    I want to call a member function in a combobox delegate placed in a particular cell to dynamically change it's contents.

    I don't see any way to access this?? Cannot get a pointer to it..so is this possible? If not WHY not..seems like it should be simple to do...

    I do NOT want to destroy it and re-create it each time it changes, this takes too long..

    Every spread sheet program lets you do something like this..so why is this not documented anywhere I can see...

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Where are you getting this data from ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • O Offline
        O Offline
        OldCoder53
        wrote on last edited by
        #3

        Data comes from a model as an int to set the combobox.

        I managed to do this:
        ComboBoxDelegate *TypeDelegate; // our custom drop box

        // Make sure we are at the selected row in tableview....
        TypeDelegate =(ComboBoxDelegate *)ui->IDC_SLIST->itemDelegateForColumn(1);
        TypeDelegate->SetCmdSet(Sel); // tell drop what list to load

        This seems to work ok, but not sure casting is typesafe or the right way to do it...
        IDC_SLIST is a TableView

        Ken

        mrjjM 1 Reply Last reply
        0
        • O OldCoder53

          Data comes from a model as an int to set the combobox.

          I managed to do this:
          ComboBoxDelegate *TypeDelegate; // our custom drop box

          // Make sure we are at the selected row in tableview....
          TypeDelegate =(ComboBoxDelegate *)ui->IDC_SLIST->itemDelegateForColumn(1);
          TypeDelegate->SetCmdSet(Sel); // tell drop what list to load

          This seems to work ok, but not sure casting is typesafe or the right way to do it...
          IDC_SLIST is a TableView

          Ken

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          The c cast is not optimal. we have qobject_cast which is safer.

          TypeDelegate =   qobject_cast<ComboBoxDelegate *> ( ui->IDC_SLIST->itemDelegateForColumn(1) );
          if (TypeDelegate ) { // check if cast worked
          TypeDelegate->SetCmdSet(Sel); // tell drop what list to load
          }
          
          1 Reply Last reply
          1
          • O Offline
            O Offline
            OldCoder53
            wrote on last edited by
            #5

            Thanks for that, I will update the code

            Ken

            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