Hi there!
I'm new to Qt programming. Well, I already used Qt 3 before, but I only made modifications to an existing application, the main design came from someone else. Now I'm going to learn Qt4. And this forum seems to be an excellent resource. I'm only sorry that for now I only have questions and cannot help others here. So, here comes a big thank you for those who do.
There is one basic question have, about global variables. They seem to be considered bad programming style, and normally I also try to avoid them. On the other hand, the old Qt3 projects I was also working on always had a single global variable, a pointer to the main object. Whatever subroutine I was in, I always could acess the data I needed.
Example: My little Qt4 testing project draws some geomtric figure (e.g. a circle), and there is a slider to change the radius. Simple, even for my standards :) Now I added an input field and a dial as alternative ways to set the radius. So when the slider is changed, the other two widgets should change accordingly.
I guess I should connect those widgets, so when the slider is changed, the other two widgets get the signal to change accordingly. But how do I prevent them to:
- Send signals back to the slider widget, avoiding an infinite cascade of events
- Prevent the other widgets from also updating the draw area again
And how do I get the current radius in other parts of my application? I solved this by simply creating my global pointer to the main object, which has an int m_radius that gets set in the event handlers (and according getRadius() and setRadius() methods). But this does not seem to be the recommended way of doing it.
Well, how do you do this?
Thanks for reading, and sorry if these questions are too stupid,
Wonk0
Bookmarks