#include <gtk/gtk.h>
#include <string>
using namespace std;
class WIN
{
protected:
GtkWidget *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;
}
答案 0 :(得分:2)
似乎gtk_widget_show()返回void。这是你以无效的方式使用的无效表达。
答案 1 :(得分:1)
gtk_widget_show()
返回void。
您正在致电obj1.set_window(void)
变化:
obj1.set_window(gtk_widget_show(w));
要
gtk_widget_show(w);