大家好,我正在使用 C 和 GTK+ 2 我想制作一个像 MS 程序这样的简单绘图程序,但是通过这两个工具就可以了
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *drawingArea;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(gtk_main_quit), G_OBJECT(window));
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit),
G_OBJECT(window));
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
drawingArea = gtk_drawing_area_new();
/*The problem is in the next line */
gtk_drawing_area_size(G_OBJECT(drawingArea), 200, 200);
gtk_container_add(GTK_CONTAINER(window), drawingArea);
gtk_widget_show(drawingArea);
gtk_widget_show(window);
gtk_main();
return 0;
}
我的问题在注释行中
gtk_drawing_area_size(G_OBJECT(drawingArea),200,200);
编译时的错误
ibrahim@ibrahim-PC:~/Desktop$ gcc main.cpp -o base `pkg-config --cflags --libs gtk+-2.0`
main.cpp: In function ‘int main(int, char**)’:
main.cpp:14:52: error: cannot convert ‘GObject* {aka _GObject*}’ to ‘GtkDrawingArea* {aka _GtkDrawingArea*}’ for argument ‘1’ to ‘void gtk_drawing_area_size(GtkDrawingArea*, gint, gint)’
所以请帮助我