Selecting QComboBox in QTableWidget

后端 未结 4 1284
情书的邮戳
情书的邮戳 2021-02-13 02:10

One cell in each row of a QTableWidget contains a combobox

for (each row in table ... ) {
   QComboBox* combo = new QComboBox();      
   table->setCellWidget         


        
4条回答
  •  旧巷少年郎
    2021-02-13 02:58

    No need for the signal mapper... When the combobox is created you can simply add two custom properties to it:

    combo->setProperty("row", (int) nRow);
    combo->setProperty("col", (int) nCol);
    

    In the handler function you can get a pointer back to the sender of the signal (your combobox).

    Now by asking for the properties you can have your row/col back:

    int nRow = sender()->property("row").toInt();
    int nCol = sender()->property("col").toInt();
    

提交回复
热议问题