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. Display of QComboBox in QTableView

Display of QComboBox in QTableView

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtableview c++qcombobox
4 Posts 3 Posters 485 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.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #1

    Good afternoon,
    I have maybe not so large but complex set of data to be displayed in QTableView. In general it is custom user database stored in in-memory sqlite. Nothing out of ordinary. This display is read only. Data is supplied by standard QSqlTableModel, data is static as refreshing the model requires fresh poll from external source.
    However in a few columns data is a set of mail addresses - in order no to clutter or stretch columns too wide I'd like to display them as combo box in the cell - so user that needs to check can just expand the box to see the emails. I wrote a relevant delegate and it works... but only if I trigger edit event on the cell (double click or whatever is set). I might misinterpret docs but it is written:
    The items shown in a table view, like those in the other item views, are rendered and edited using standard delegates.
    For performance reasons I'd like to avoid inserting combo boxes as widgets - with 500 users, four columns with such data...
    Is there something else I can do? Or am I wrong and inserting so many widgets will have minimum impact on performance?

    Stack: Qt6, qmake, macOS/Windows/Linux.

    Many thanks for any insight.

    For more information please re-read.

    Kind Regards,
    Artur

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

      Hi,

      If memory serves well, you might be able do to what you want using QStyledItemDelegate::editorEvent.

      Hope it helps

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

      artwawA 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        If memory serves well, you might be able do to what you want using QStyledItemDelegate::editorEvent.

        Hope it helps

        artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #3

        @SGaist Looking into it, thank you! Will post once I check.

        For more information please re-read.

        Kind Regards,
        Artur

        JonBJ 1 Reply Last reply
        0
        • artwawA artwaw

          @SGaist Looking into it, thank you! Will post once I check.

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

          @artwaw
          I'm not sure, but in addition to @SGaist you may also find you want to use https://doc.qt.io/qt-5/qabstractitemview.html#openPersistentEditor ?

          1 Reply Last reply
          1

          • Login

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