@table = Qt::TableWidget.new(@central_widget)
@table.objectName = 'tableWidget'
@table.geometry = Qt::Rect.new(250, 110, 340, 200)
@table.columnCount = 3
labels = ['Category', 'ID', 'Points']
column_items = []
combo_boxes = []
3.times {|n| column_items[n] = Qt::TableWidgetItem.new
column_items[n].text = labels[n]
@table.setHorizontalHeaderItem(n, column_items[n])
combo_boxes << Qt::ComboBox.new(@table)
combo_boxes[n].objectName = "comboBox_#{n+1}"
combo_boxes[n].maxVisibleItems = 4
combo_boxes[n].insertItems(0,['Dairy', 'Bread', 'Meat', 'Sauce'])
combo_boxes[n].sizeAdjustPolicy = Qt::ComboBox::AdjustToContents
@table.setCellWidget(n + 1, 1, combo_boxes[n])
}
@table.rowCount = 3 if @table.rowCount < 1
@table.resizeColumnsToContents
@table = Qt::TableWidget.new(@central_widget)
@table.objectName = 'tableWidget'
@table.geometry = Qt::Rect.new(250, 110, 340, 200)
@table.columnCount = 3
labels = ['Category', 'ID', 'Points']
column_items = []
combo_boxes = []
3.times {|n| column_items[n] = Qt::TableWidgetItem.new
column_items[n].text = labels[n]
@table.setHorizontalHeaderItem(n, column_items[n])
combo_boxes << Qt::ComboBox.new(@table)
combo_boxes[n].objectName = "comboBox_#{n+1}"
combo_boxes[n].maxVisibleItems = 4
combo_boxes[n].insertItems(0,['Dairy', 'Bread', 'Meat', 'Sauce'])
combo_boxes[n].sizeAdjustPolicy = Qt::ComboBox::AdjustToContents
@table.setCellWidget(n + 1, 1, combo_boxes[n])
}
@table.rowCount = 3 if @table.rowCount < 1
@table.resizeColumnsToContents
To copy to clipboard, switch view to plain text mode
Bookmarks