[linux-audio-dev] Re: MVC

Paul Davis paul at linuxaudiosystems.com
Sat May 10 17:24:01 UTC 2003

>QPushButton * b1 =3D new QPushButton( this );
>QPushButton * b2 =3D new QPushButton( this );
>b1->setToggleButton( true );
>b2->setToggleButton( true );
>connect( b1, SIGNAL( toggled( bool ) ), b2, SLOT( setOn( bool ) ) );
>connect( b2, SIGNAL( toggled( bool ) ), b1, SLOT( setOn( bool ) ) );
>You might expect, that this would result in an infinite loop but actually t=
>toggled signal is only emitted if the button was really toggled. So calling=
>setOn( true ) on a already "on" button won't change it's state so it won't=
>emit the according signals.

thats not really the question at all. the question is: can i set the
button ("view") to show some state in the model without it appearing
that the user pressed the button?

>class Model
>  public:
>    Model();
>  private slots:
>    void viewChanged( int value );
>  private:
>    View *_view1, *_view2;

instant violation of the core of MVC. Models don't know about
Views. that's why MVC is so powerful: you can create multiple views
(and multiple controls) for the same model without changing anything
about the model's implementation. it has no clue how its state is
being presented, and doesn't care. likewise, it doesn't care how many
different sources there are of state changes. they could come from the
keyboard, the mouse, a USB device, a MIDI device, a radio interface,
an ethernet interface etc. etc. each one is independent of all others
(and often is independent of the views too).


More information about the Linux-audio-dev mailing list