Selecting QComboBox in QTableWidget

后端 未结 4 1283
情书的邮戳
情书的邮戳 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:55

    Just got same problem and this is how I solved. I use QPoint that is a cleaner way to save a x-y value than a QString. Hope this helps.

    classConstructor() {
        //some cool stuffs here
        tableVariationItemsSignalMapper = new QSignalMapper(this);
    }
    
    void ToolboxFrameClient::myRowAdder(QString price) {
        QLineEdit *lePrice;
        int index;
        //
        index = ui->table->rowCount();
        ui->table->insertRow(index);
        //
        lePrice = new QLineEdit(price);
        connect(lePrice, SIGNAL(editingFinished()), tableVariationItemsSignalMapper, SLOT(map()));
        tableVariationItemsSignalMapper->setMapping(lePrice, (QObject*)(new QPoint(0, index)));
        // final connector to various functions able to catch map
        connect(tableVariationItemsSignalMapper, SIGNAL(mapped(QObject*)),
                 this, SLOT(on_tableVariationCellChanged(QObject*)));
    }
    
    void ToolboxFrameClient::on_tableVariationCellChanged(QObject* coords) {
        QPoint *cellPosition;
        //
        cellPosition = (QPoint*)coords;
    }
    

提交回复
热议问题