1
votes

It's right to make connection with slot and signal like a

connect( ui->widget, SIGNAL( GetSquareParameters( int &, int &,int &,int &)), this, SLOT( SendSliderParams( int &, int &,int &,int &) ) ); 

If I need to get mouse coords from QMouseEvent and need to get parameters from some sliders of the MainWindow. I create signal GetSquareParameters in the Scene and SendSliderParams slot in MainWindow. Scene is a subclass from QGLWidget.

I think it's don't right way to implement that. Maybe I can connect somehow QMouseEvent in Mainwindow only if Event happen in widget(Scene) and call function like widget.AddElement( red, green, blue,... ). Have another way to implement that without using slots and signals?

1
can you explain what are you trying to do, please? It is not very clear from your question..thank uandrea.marangoni

1 Answers

1
votes

If I understand correctly what you are trying to do, then using signals and slots that way definitely seems wrong, since it will utterly break for queued connections.

You should probably do it the other way, send signals to the scene when ever the slider values change. Then add member variables for the values into the scene. So scene always knows the slider values, and does not need to ask them.