I'm in practice of writing GUI for Linux using gtkmm. Program works fine when all Widget objects are local; (inside main() c++ function). However, for my own purpose, I want to make object of Gtk::Entry as global so that the object will be used in both main method and my own method, and also for on_clicked() event method. This is my example of simple code......
#include <gtkmm.h>
#include <iostream>
using namespace std;
using namespace Gtk;
Entry entry; //Trying to make it visible to any block of codes
int main(){
Main kit(argc, argv);
Window window;
wind.resize(300,300);
//Widgets
//.
//.
//.
//Entry entry; //if I create here Entry object, no runtime error!
//but will not be accessible to other blocks.
entry.set_text("Sample text");
entry.show();
//...
}
//I want the same Entry object to be accessed here
void myOwnMethod(){
entry.set_text("Updated text");
}
I'm familiar with Java Swing, so it seems these GTK policies are very confusing to me. Also it looks like entry variable is not initialized, but I tested other objects of non-GTKMM class but work even I make them to be global. GUI not appear but console display series of error like:
(process:7678): Gtk-CRITICAL **: _gtk_style_cascade_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
the last error is: (MyProg:7678): Gtk-CRITICAL **: _gtk_style_cascade_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed Segmentation fault
Unfortunately, I dont't know also how on_clicked
event method can use argument so that I can pass even local variable.
Please help me...