thanks Niko. I knew it was just a matter of time before someone would sling a Singleton solution at me. I tried incorporating your solution but get aerror. But let me step back a bit first:setNum is not a member of 'Window'
1. my "class Window" is my primary/main application window class with references to 100+ top-level widgets, etc. Confusing, perhaps, since it derives from QWidget and not QMainWindow; I may change this later. Anyway, given this fact, perhaps I need to go about this a different way, because...
2. from the Wiki I see that a primary use of Singletons is "to encapsulate global variables", which is why I would want to use it here, of course. Here's where I'm confused: the Wiki example provides an example of a Singleton class, including things like a your getInstance() method, and a private constructor (which you left public). In *your* example, however: are you simply saying that I can create a class, Window, that is normal in most respects, yet has some singleton-pattern methods to enable access to a specific QLabel? If true, then I think this might be the best way for me to do it, since I will only have 5 or so QWidgets in Window that need to be accessed by non-Qt parts of the program. But if *not* true:
3. Perhaps the best thing to do: create a separate Singleton class (like in the Wiki) and put all my global variables there... so that they can be accessed by both Window and the non-Qt parts of my application?
Bookmarks