2014-02-26 177 views
0
void Scene::mousePressEvent(QMouseEvent * iEvent) 
{ 
    Square temp; 

    emit GetSquareParameters(temp.color.red, temp.color.green, temp.color.blue, temp.size); 

    m_Squares.push_back(temp); 
} 

我從QMouseEvent獲得鼠標座標並需要從MainWindow的某些滑塊獲取參數。我在SceneMainWindow的SendSliderParams插槽中創建信號GetSquareParametersQt信號和插槽通過參考

信號和時隙中conected像
connect(ui->widget, SIGNAL(GetSquareParameters(int, int,int,int)), this, SLOT(SendSliderParams(int, int,int,int)));

我可以通過由用於信號和參考時隙後面PARAMS?如果不是我能如何實現我想要的行爲?

回答

1

沒有一個信號呼叫純粹是1種方式多於1個時隙可以被連接到一個信號(反之亦然)

既可以使之成爲真正的函數調用在這裏可以作爲參考

做通

或創建一個與回調相反方向的信號插槽連接

+1

或者您可以在信號中傳遞指針... – Archie

+0

connect(ui-> widget,SIGNAL(GetSquareParameters(int&,int&,int &,int&)),這個,SLOT(SendSliderParams(int&,int&,int&,int &))); 我連接這樣,它幫助。 – YYY

+1

這是不正確的,有可能以相反的方向傳遞值,請參閱Qt中的d-bus示例。但是,這是非常不推薦的,它很難維持(牀設計)。我會避免這個代價。 –