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. QComboBox in QTableWidgetItem of Header

QComboBox in QTableWidgetItem of Header

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k 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.
  • K Offline
    K Offline
    Kritika
    wrote on last edited by
    #1

    I am using QTableWidget, in this i want one of the column heading as QCombobox. Other column headings are strings which is its normal functionality. Can anyone tell me how to use qwidget in one of headerItem?

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

      Hello,

      for the moment I can see two possible solutions, but I don't have time to test them.

      In first solution You can try to use "QTableWidget::setHorizontalHeaderItem() method":http://qt-project.org/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderItem to place there a QComboBox. You can subclass the "QTableWidhetItem":http://qt-project.org/doc/qt-4.8/qtablewidgetitem.html and maybe this will work.

      -_ If above solution won't work, please note that QTableWidget's header is implemented with class "QHeaderView":http://qt-project.org/doc/qt-4.8/qheaderview.html . _-
      I wanted to write that QHeaderView derives from QAbstractItemView and You can try to write custom delegate, but the I have notice in QHeaderView's documentation that: "Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect."
      So no item delegate would work....

      Try to check this topic for the solution: "http://www.qtcentre.org/threads/27077-Quick-way-for-QWidget-in-QHeaderView-s-columns":http://www.qtcentre.org/threads/27077-Quick-way-for-QWidget-in-QHeaderView-s-columns

      Hope that will help You,

      poorBob

      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