开发者

Qt : Update Multiple values on a Button Click

I am facing a problem regarding Signals and Slots mechanism of Qt. The core of the problem is here :

My application consists of 2 classes:

MainGUI : this class has all the core functionality of the app, and has some variables which store values relevant to the app.

Preferences : This class is used to draw and show a Settings panel, and has line-edit fields for updating the variables in MainGUI (using Signal-Slot mechanism)

Currently, i have connected them as follows:

Preferences *Pref;
MainGUI *M;
.
.
.
connect(Pref, SIGNAL(pref_varAChanged(QString)), M, SLOT(setVarA(QString)));
connect(Pref, SIGNAL(pref_varBChanged(QString)), M, SLOT(setVarB(QString)));
connect(Pref, SIGNAL(pref_varCChanged(QString)), M, SLOT(setVarC(QString)));
.
.
.

But, what this part do开发者_JS百科es is that AS SOON AS the values are changed, the variables are updated, even though i have not click on 'APPLY' button (or an equivalent ACCEPT button...)

Please help me in implementing this functionality that the values A,B,C get updated only when a button, say, btn_accept is clicked...

PS : I know this seems a very easy problem, and should be only a few lines long, but i've been trying to solve it and have been hitting the wall every time. I'd appreciate if someone could point me in the right direction


Well, it seems i have figured out the problem. It was simply a matter of emitting the 'variableChanged' signals when the ACCEPT button was clicked. This would update the variables in the MainGUI class.

It seems I had found the solution (read my comment), but I had misread the output my program gave, thus I had not realized that I had solved the problem until much later.

Thank you all for your comments. I'm sorry that this turned out to be such a waste of time.

Regards,

Harsh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜