Re: [gtkmm] Spawning a new windows from toplevel window



Max Vasin wrote:
Jaroslaw Mroczek <jaroslaw mroczek wp pl> writes:


Hello everybody

	I write program for analizing ECG signals (viewer, R peak
detector, PVC detector, ...). I wrote everything in C++ and designed
GUI in GTKmm. Main window of my aplication is represented by EcgMain
class (public Gtk::Window(TOPLEVEL)). It's responsible for making
general operations on signal records (opening, saving,...). So I have
method
EcgMain::on_open_file() which is responsible for opening new signal
record and spawning new window with record (class SignalWindow : public
Gtk::Window as well).
	To spawn a new toplevel signal window in on_open_file() i used
Gtk::Main:run(m_signal_window_object). Simple code doing this looks in
my program as follows:

... // finding signal record and loading to memory

SignalWindow m_signal_window(pointer_to_signal_record) ; // new window
Gtk::Main:run(m_signal_window); // launch new window

Wrong!!! Gtk::Main:run starts the event loop - I don't think it
is a good idea to launch it twice or more.

	The problem is of course when I open a few signal windows and
want to close one of them. In SignalWindow class I have overriden
on_delete_event() method. When I want to close single signal window
there is Gtk::Main::quit() call inside on_delete_event(). Window is
closed of course but not this one which I wanted to close, but this
which was last launched by Gtk::Main:run. My question is quite simple.
How can I spawn new window from main one without calling Gtk::Main::run
or how can I close single window (this one which I want to close, not
the last opened) ??

Well it is quite simple - you just have to create a new window object and
then show the window. You should use somethining like
Thank you very much for helping me.
Yes, obviously it is simple ... if you don't forget to allocate memory for Window what I did in my app ;).

SignalWindow* m_signal_window = new SignalWindow(pointer_to_signal_record);
m_signal_window->show();

With the code:

SignalWindow m_signal_window ;
m_signal_window.show();

it simply doesn't work.

Thank you very much

	static_cast<Happy>(RedBull)



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