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. How to make Widget always show in QTableView
Qt 6.11 is out! See what's new in the release blog

How to make Widget always show in QTableView

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

    There is a very strange request....

    In most time ,QTableView + Model + QItemDelegate ,when need to DoubleClick a item in tableview,and then this item will "produce" a MyWidget ( or anyother widget inherit QWidget),it will be implement by QItemDelegate ,like

    QWidget* MyDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index){
         MyWidget* w = new MyWidget(parent);
        return w;
    }
    

    When user DoubleClicke any item in QTableView,the item will replaced by MyWidget.

    Now there is a request, one column int QTableView,every item of this column must be replaced by MyWidget, when the GUI(QTabelView) show.

    it don't depend on user DoubleClick item, and show MyWidget int item

    So how to do this?

    1 Reply Last reply
    0
    • qazaq408Q Offline
      qazaq408Q Offline
      qazaq408
      wrote on last edited by
      #2

      i got it!!

      tableview->openPersistentEditor(model->index(0,0);
      tableview->openPersistentEditor(model->index(0,1);
      tableview->openPersistentEditor(model->index(0,2);
      tableview->openPersistentEditor(model->index(0,3);
      
      1 Reply Last reply
      0
      • qazaq408Q qazaq408 has marked this topic as solved on

      • Login

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