#include <gtk/gtk.h>
#include <string>
using namespace std;
class WIN
{
protected:
Gt开发者_运维百科kWidget *window;
public:
GtkWidget* get_window(){ return window; }
void set_window(GtkWidget* w){ window = w; }
void set_title(string s)
{
gtk_window_set_title (GTK_WINDOW(window), s.c_str());
}
};
int main (int argc, char *argv[])
{
/* Initialize GTK+ and all of its supporting libraries. */
gtk_init (&argc, &argv);
WIN obj1;
obj1.set_window(gtk_window_new (GTK_WINDOW_TOPLEVEL));
obj1.set_title("Hello World");
GtkWidget *w = obj1.get_window();
obj1.set_window(gtk_widget_show(w));
/* Hand control over to the main loop. */
gtk_main();
return 0;
}
Seems like gtk_widget_show() returns void. That's the void expression you are using in an invalid way.
http://library.gnome.org/devel/gtk/2.99/GtkWidget.html
gtk_widget_show()
returns void.
You're calling obj1.set_window(void)
Change:
obj1.set_window(gtk_widget_show(w));
To
gtk_widget_show(w);
精彩评论