Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:43:14+00:00 2026-06-07T16:43:14+00:00

Hello guys I’m using C and GTK+ 2 I want to make a simple

  • 0

Hello guys I’m using C and GTK+ 2 I want to make a simple paint program like MS program but by these two tools only okay I just started and I want your hands to reach the end 🙂
look to my code here

#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;
}

my problem is in the commented line

gtk_drawing_area_size(G_OBJECT(drawingArea),200,200);

the error when compiling

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)’

So Please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:43:17+00:00Added an answer on June 7, 2026 at 4:43 pm

    That’s a common gotcha in GTK+. You have to cast the widget to the type that exposes the method (i.e. the implementing type). You should write:

    gtk_drawing_area_size(GTK_DRAWING_AREA(drawingArea), 200, 200);
    

    Instead of:

    gtk_drawing_area_size(G_OBJECT(drawingArea), 200, 200);
    

    Because the GObject type does not support the gtk_drawing_area_size() method, but the GtkDrawingArea type does.

    (Actually, it’s more like gtk_drawing_area_size() does not support taking a GObject instance, since GTK+’s object oriented nature is abstracted that way in C.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys. I think it isn't possible just using PHP, but just to be
Hello Guys! Using firefox plugins I can capture headers. I want to do it
Hello guys I need to make a simple android quiz. Well what I've done
Hello guys I can't provide the code but you can see it on the
hello guys I am trying to extract all the anchor links from aol but
hello guys i am try to print the output of two element data simultaneously
Hello guys Im using advance notification manager this is the code Notification note =
Hello Guys I am working on WPF app and I want to Unlike the
Hello Guys I am working WPF app and I want to retrive all the
* Hello Guys..! * Normally a java program needs main() function to execute the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.