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. Adding widgets to a TableWidget?
Forum Updated to NodeBB v4.3 + New Features

Adding widgets to a TableWidget?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.7k Views 1 Watching
  • 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
    itsmemax
    wrote on last edited by
    #1

    Hi again with (hopefully) my last question. Is there any way to place a widget into an empty TableView grid? Actually I need buttons into 64 grids, to open filenames. Thanks ;)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      You can have a look at "this":http://qt-project.org/forums/viewthread/16673 topic.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        itsmemax
        wrote on last edited by
        #3

        Wait a moment, it's a QTableWidget, not a QTableView, sorry! I've edited the title.

        I've tried it like this:
        @ ui->tableWidget->setCellWidget(3, 1, QPushButton);@

        but I'm getting the following error:
        expected primary-expression before ')' token

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          Maybe
          @ui->tableWidget->setCellWidget(3, 1, new QPushButton());@

          1 Reply Last reply
          0
          • I Offline
            I Offline
            itsmemax
            wrote on last edited by
            #5

            I've did it myself already:

            @ QPushButton *OttoButton = new QPushButton();
            ui->tableWidget->setCellWidget(1,3,OttoButton);@

            Thanks anyway

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sam
              wrote on last edited by
              #6

              You need to add an instance of the widget as specified by qxoz . Check "setCellWidget":https://qt-project.org/doc/qt-5.0/qtwidgets/qtablewidget.html#setCellWidget documentation.

              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