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. QTableView placing widgets inside cells
Forum Updated to NodeBB v4.3 + New Features

QTableView placing widgets inside cells

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 595 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.
  • I Offline
    I Offline
    ikuris
    wrote on last edited by ikuris
    #1

    Hello,
    I want to place some multiple widgets(at least 2)(2 combo box or line edit) inside one column every row how can I accomplish that?
    I have seen some examples with QStyledItemDelegate but I couldnt find with multiple widget examples.
    I saw an exaple from https://stackoverflow.com/questions/51577711/qstyleditemdelegate-how-to-make-two-widgets-in-one-row, but I didnot understand how he did associate widgets with columns, for example,

    model->setData(index, widget->text(), Qt::DisplayRole);
    

    What if I do have more than one column with Qt::DisplayRole, and I understand with this method the widgets are visible only in edit mode is it true?.

    Thank you for your time.

    JonBJ 1 Reply Last reply
    0
    • I ikuris

      Hello,
      I want to place some multiple widgets(at least 2)(2 combo box or line edit) inside one column every row how can I accomplish that?
      I have seen some examples with QStyledItemDelegate but I couldnt find with multiple widget examples.
      I saw an exaple from https://stackoverflow.com/questions/51577711/qstyleditemdelegate-how-to-make-two-widgets-in-one-row, but I didnot understand how he did associate widgets with columns, for example,

      model->setData(index, widget->text(), Qt::DisplayRole);
      

      What if I do have more than one column with Qt::DisplayRole, and I understand with this method the widgets are visible only in edit mode is it true?.

      Thank you for your time.

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

      @ikuris said in QTableView placing widgets inside cells:

      What if I do have more than one column with Qt::DisplayRole

      What exactly do you mean by this?

      I would first try to re-evaluate what you are trying to achieve? You should not be storing more than one value in a cell (model index), and you ought not be needing these multiple widgets. And btw an editable combo can contain both values for the user to pick from and allow any value to be typed.

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        maybe try to create a qwidget with hboxlayout. Then add combox and line edit to it.
        table_view->setIndexWidget( index, qwidget);

        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