c++ - Trouble embedding a QComboBox in a QTableWidget -


I am creating a GUI using QT, and I would like to be a combo box in the last entry in my table. It is an idea that the user has permission to select new items to be put in a drop-down list from the table.

Do I think this combo box is embedded inside a table cell? I have tried to:

  table_widget = new QTableWidget (1, 9, dialog); table_widget-> SetObjectName (QStringLiteral ("table_widget")); Add_part_combo = new QComboBox (table_widget); add_part_combo-> SetObjectName (QStringLiteral ("add_part_menu")); Add_part_combo-> AdiTem (Cuestring Literature ("Import new items ..."); Table_widget-> Setc widget (1, 1, add_part_combo);   

If I create a combo box with the dialog , then it puts the combo box in the upper left corner of the dialog (under some / em> table). If I make it with table_widget instead, then the combo box appears at the top of the table (at the top of the first header cell). If I do not provide a native widget, then it does not appear at all.

But under any circumstances the widget does not actually appear in cell 1.1

What is I doing wrong?

line and columns setCellWidget The parameters passed near are zero-indexed. In addition, you do not need to provide a parent for QComboBox because when setsCellWidget calls, then QTableWidget will accept its ownership . As such, your code should be as follows:

  add_part_combo = new QComboBox; add_part_combo-> SetObjectName (QStringLiteral ("add_part_menu")); Add_part_combo-> AdiTem (Cuestring Literature ("Import new items ..."); // Note: Row and column 0, no 1. Table_digit- & gt; Set setwell valve (0, 0, ad_parti_combo);    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -