Re: Running the main loop in a separate thread

Ok , this is driving me crazy - I wrote an example program just to try it and - yes - even if there's only one main loop in the simplest of applications the gtkmm window doesn't get destroyed before the process ( main() )ends . Now what's up with that ? Isn't there a way my application isn't all dependent on gtkmm (as in : can I , in normal circumstances , close my main window and have it disappear from the users view, before ending the program?) . Here's an example taken out of the tutorial on (not to bother you with my own messy code) (the only thing I added was sleep(2);). The app launches and on close the window doesn't disappear but hangs till the process ends:

class HelloWorld : public Gtk::Window

  virtual ~HelloWorld();

  //Signal handlers:
  void on_button_clicked();

  //Member widgets:
  Gtk::Button m_button;

: m_button("Hello World") // creates a new button with label "Hello World".
  // Sets the border width of the window.

  // When the button receives the "clicked" signal, it will call the
  // on_button_clicked() method defined below.

  // This packs the button into the Window (a container).

  // The final step is to display this newly created widget...;


void HelloWorld::on_button_clicked()
  std::cout << "Hello World" << std::endl;


int main (int argc, char *argv[])
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

  HelloWorld helloworld;

  //Shows the window and returns when it is closed.

  return 0;

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