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
QtWS25 Last Chance

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.
  • A Offline
    A Offline
    artwaw
    wrote on 6 Jan 2021, 18:19 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Jan 2021, 18:38 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

      A 1 Reply Last reply 6 Jan 2021, 18:43
      1
      • S SGaist
        6 Jan 2021, 18:38

        Hi,

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

        Hope it helps

        A Offline
        A Offline
        artwaw
        wrote on 6 Jan 2021, 18:43 last edited by
        #3

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

        For more information please re-read.

        Kind Regards,
        Artur

        J 1 Reply Last reply 6 Jan 2021, 18:44
        0
        • A artwaw
          6 Jan 2021, 18:43

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

          J Online
          J Online
          JonB
          wrote on 6 Jan 2021, 18:44 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

          4/4

          6 Jan 2021, 18:44

          • Login

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