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
的某些滑塊獲取參數。我在Scene
和MainWindow
的SendSliderParams插槽中創建信號GetSquareParameters
。Qt信號和插槽通過參考
信號和時隙中conected像
connect(ui->widget, SIGNAL(GetSquareParameters(int, int,int,int)), this, SLOT(SendSliderParams(int, int,int,int)));
我可以通過由用於信號和參考時隙後面PARAMS?如果不是我能如何實現我想要的行爲?
或者您可以在信號中傳遞指針... – Archie
connect(ui-> widget,SIGNAL(GetSquareParameters(int&,int&,int &,int&)),這個,SLOT(SendSliderParams(int&,int&,int&,int &))); 我連接這樣,它幫助。 – YYY
這是不正確的,有可能以相反的方向傳遞值,請參閱Qt中的d-bus示例。但是,這是非常不推薦的,它很難維持(牀設計)。我會避免這個代價。 –