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. A delegate works fine in one QTableView but not visible in an other - what might be the issue?
Qt 6.11 is out! See what's new in the release blog

A delegate works fine in one QTableView but not visible in an other - what might be the issue?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 641 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.
  • O Offline
    O Offline
    olowo726
    wrote on last edited by
    #1

    Hi,

    I have a delegate which just overrides createEditor and setEditorData to create a label which displays a pixmap. This works perfectly fine in one table view in a dialog but the label isn't shown in a second, different, dialog, which uses a different QTableView with a different model but the same delegate.

    • My code does call openPersistentEditor in both cases.
    • createEditor in the delegate gets called and successfully creates the label.
    • setEditorData is called once.
    • flags() in the model returns identical values for both cases.
    • The model provides the correct data (since there delegate qlabel isn't shown the qtableview displays the data as string instead and it's correct)

    Any idea of what I might be missing? Some special setting in the table view which is required for delegates to be positioned correct?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @olowo726 said in A delegate works fine in one QTableView but not visible in an other - what might be the issue?:

      but the same delegate

      What does this mean? Hopefully these are two different instances:
      Warning: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

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

        yes, there is two difference instances of the same class.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The please provide a minimal, compilable example.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • O Offline
            O Offline
            olowo726
            wrote on last edited by
            #5

            Solved: The view destroys all delegates when the model is reset. In hindsight one can say that this is obvious but it wouldn't hurt if it was included in the documentation.

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Sorry but I don't think you're right, see QAbstractItemView::setItemDelegate(): QAbstractItemView does not take ownership of delegate.

              Please provide a minimal, compilable example.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              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