Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt5 - QPushButton to add row to a QTableView
Forum Updated to NodeBB v4.3 + New Features

PyQt5 - QPushButton to add row to a QTableView

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 1 Posters 1.1k 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.
  • P Offline
    P Offline
    PiroDev
    wrote on last edited by
    #1

    Re: PyQT5 - Button to add row to a QTableView

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PiroDev
      wrote on last edited by
      #2

      You can implement 'add row to QTableView' action for button in that way:

      from PyQt5.QtGui import QStandardItemModel, QStandardItem
      ...
      table = QTableView(...)
      table.setModel(QStandardtemModel())
      addRowButton = QPushButton('Add row', ...)
      addRowButton.clicked.connect(lambda: table.model().insertRow(0, [QStandardItem('1'), QStandardItem('example'), ...])
      
      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