2
Hello guys我正在使用C和GTK + 2我想製作一個像MS程序這樣簡單的繪畫程序,但是隻有這兩個工具才行,我剛開始,我希望你的雙手達到結尾:) 外觀在這裏我的代碼gtk_drawing_area_size第一個參數
#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);
錯誤編譯
[email protected]:~/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)’
時10
所以請幫幫我
As的文檔中提到['gtk_drawing_area_size'](HTTP:/ /developer.gnome.org/gtk/2.24/GtkDrawingArea.html#gtk-drawing-area-size)請考慮使用['gtk_widget_set_size_request'](http://developer.gnome.org/gtk/2.24/GtkWidget.html# GTK的插件 - 組 - 大小 - 請求) – 2012-07-14 17:45:19