Home > other >  QTableWidget Settings and delete cellwidget problem
QTableWidget Settings and delete cellwidget problem

Time:04-18

Do a QTableWidget 17 rows 9 columns, in the first column need to achieve such effect, double click on the first column of a unit, the unit shows QComboBox, then select a project, as the unit of content, and access to the content, can only show the content and not show QComboBox, then double click again, repeat the above operation, I know that can be used to entrust to handle, but some trouble, whether can use setCellWdget (), removeCellWidget (), cellWidget () three functions to implement this action? RemoveCellWidget () what is the effect, looks like does not delete the QComboBox, once again set a certain cell widget to QComboBox, abnormal program will quit, don't know what's wrong, the code shows as follows: the function response, double-click events treecomboxs, initialization labels were already good QVector, 17 elements, are one unit code simply click again on the test of time, will the abnormal exit, said in the help document, set up new cellwidget will automatically replace the previous cellwidget, I tried is not successful, so added removeCellWidget try, can guarantee program elsewhere is no problem, just post bugs in code, void ParameterTable: : onDoubleClickedCell (int row, int column) {if (column==0) {this - & gt; RemoveCellWidget (row, 0); This - & gt; SetCellWidget (row, 0, treecomboxs (row)); This - & gt; RemoveCellWidget (row, 0); This - & gt; SetCellWidget (row, 0, labels (row)); }}

CodePudding user response:

The realization of the best way is to write the delegate.

CodePudding user response:

You put your view of the procession combox value with QStringList assignment double-click automatically

CodePudding user response:

QTableWidget insert widgets in hide and show if you delete the widget you will find that the memory deleted interface does not delete the memory is equal to the memory or have not been deleted

CodePudding user response:

The building Lord solved? I now also in this ComboBox as if can only be used once
  • Related