Re: How to show new window?



> Well, right :-P
> 
> But the way that glade creates the widgets, where myWindowName has a public
> of
> myWindowName_glade, which has a public of Gtk::Window and that it generates
> the code
> that pops the first window up, I figured it would be good to stick to same
> convention that
> glade uses, editing the correct files and using the right classes (since
> there are probably
> at least a dozen different ways to do it, with gtkmm, straight gtk, etc)
> 
> I got the window to pop up on startup, set it back to being not-visible, and
> then tried to use Show(),
> but it is not able to find window #2 (winConfiguration) from within window
> #1 (winOscilloscope):
> 
> winOscilloscope.cc(631): error: identifier "winConfiguration" is undefined
> winConfiguration->Show();
> 
> I've made the window public, that didn't seem to change anything. The window
> is instantiated in
> the main() function with the following:
> 
> winConfiguration *winConfiguration = new class winConfiguration();
> 
> I'm guessing that "winConfiguration" is not available within the other
> window, and I'm not sure
> how to go about making it so. Would I have to pass it in somehow, or do I
> need to move the
> instantiation into the other window somehow? I wish there were a good
> up-to-date tutorial on
> these basic concepts online somewhere, but I've searched far and wide only
> to find outdated
> information. Thanks very much for the help!

It's easy (and it's not gtk/gtkmm per se, it's plain C/C++). In
winOscilloscope.hh 

#include "winConfiguration.hh"

and in the winOscilloscope class have a member winConfiguration (either
object, or pointer). If you have a pointer, you need to allocate it. As it
stands, this is done in main. Main doesn't really need to know about
winConfiguration, but winOscilloscope does. Glade can't know that, so it
defines both windows in main, but you can put the second one wherever you
want. 

Also, the windows built by glade don't have a constructor. It leaves it to
you to write one, if needed. That's a good place to create GC, allocate
colors, etc. This is a good place to have winConfiguration allocated, if
you defined it as a pointer.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]