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. [SOLVED] Custom delegate "createEditor" never gets called
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Custom delegate "createEditor" never gets called

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k 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.
  • G Offline
    G Offline
    goblincoding
    wrote on 4 Sept 2014, 10:56 last edited by
    #1

    Good day everyone,

    Firstly, I can edit my view without the delegate without any issues (i.e. my "flags()" and "setData()" methods seem to be implemented correctly).

    Secondly, I set the delegate on the view itself via "setItemDelegate()"

    Thirdly, I have confirmed that the delegate's "setEditorData()" and "setModelData()" methods get hit every time I attempt an edit, but the "createEditor()" method is never, ever called.

    Since I've just started playing with the Model/View/Delegate idea, I have a little "playground" project where I am testing these concepts in an attempt at understanding them. The project and all the code (there isn't much) is available "here":https://www.dropbox.com/sh/k2psfo56gm1emea/AACQubfSiZeawiIPwyOvqbWXa?dl=0

    Any help will be appreciated :)

    Thanks!

    http://www.goblincoding.com

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 4 Sept 2014, 13:49 last edited by
      #2

      There is mismatch in the signature of createEditor. Please look at the warnings. It says virtual createEditor(...) is hidden by your createEditor(...). So your createEditor is different from virtual createEditor(...).

      Just try the following.

      @QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;

      QWidget *DomDelegate::createEditor(QWidget *parent,
      const QStyleOptionViewItem &option,
      const QModelIndex &index) const {

      qDebug() << "I am here-Delegate"<<endl;
      QPlainTextEdit *textEdit = new QPlainTextEdit(parent);
      //QSpinBox *box = new QSpinBox(parent);
      return textEdit;
      //return box;
      }@

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goblincoding
        wrote on 4 Sept 2014, 14:55 last edited by
        #3

        Wow, what a noob error :D

        Thank you for that Dheerendra, you are indeed correct, but I am not receiving any warnings...will look into the why of it...

        http://www.goblincoding.com

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goblincoding
          wrote on 4 Sept 2014, 15:07 last edited by
          #4

          OK, no idea why, but it seems the standard "Desktop Qt 5.3.0 GCC 64bit" kit that comes with Qt Creator does not pick these issues up. Switched to Clang and much happiness is being had all around.

          Thanks again!

          http://www.goblincoding.com

          1 Reply Last reply
          0

          1/4

          4 Sept 2014, 10:56

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved