I was trying to embed several combo boxes in a table widget in the first column and in as many rows as possible. Whenever I executed the code below that never happened. If I set the table widget as the combo box parent it shows up on the upper left corner of the table widget not in row 1 column 1 or anywhere else. If I don't set any combo box parent widget, the combo box never is never displayed. No matter what I do all the table widget cells are common cells, none of them look or work like combo boxes. Does anybody know what I should do to embed those combo boxes in the table widget?

Qt Code:
  1. @table = Qt::TableWidget.new(@central_widget)
  2. @table.objectName = 'tableWidget'
  3. @table.geometry = Qt::Rect.new(250, 110, 340, 200)
  4. @table.columnCount = 3
  5. labels = ['Category', 'ID', 'Points']
  6. column_items = []
  7. combo_boxes = []
  8. 3.times {|n| column_items[n] = Qt::TableWidgetItem.new
  9. column_items[n].text = labels[n]
  10. @table.setHorizontalHeaderItem(n, column_items[n])
  11. combo_boxes << Qt::ComboBox.new(@table)
  12. combo_boxes[n].objectName = "comboBox_#{n+1}"
  13. combo_boxes[n].maxVisibleItems = 4
  14. combo_boxes[n].insertItems(0,['Dairy', 'Bread', 'Meat', 'Sauce'])
  15. combo_boxes[n].sizeAdjustPolicy = Qt::ComboBox::AdjustToContents
  16. @table.setCellWidget(n + 1, 1, combo_boxes[n])
  17. }
  18. @table.rowCount = 3 if @table.rowCount < 1
  19. @table.resizeColumnsToContents
To copy to clipboard, switch view to plain text mode