QSignalMapper and original Sender()

前端 未结 2 1236
滥情空心
滥情空心 2021-01-14 02:43

I have a bunch of QComboBoxes in a table. So that I know which one was triggered I remap the signal to encode the table cell location (as described in Selecting

2条回答
  •  心在旅途
    2021-01-14 03:24

    I don't know exact answer, but maybe you should use: QComboBox* combo = qobject_cast(sender()) instead of QComboBox* combo = (QComboBox* )sender(). Someting like this:

    
     QObject* obj = sender();
     QComboBox* combo = qobject_cast(obj);
     if(combo)
     {
      doSomethingWithCombo(combo);
     }
     else
     {
      // obj is not QComboBox instance
     }
    
    

    But maybe QSignalMapper really substitutes itself instead of real sender...

提交回复
热议问题