Can not create object of Gtk::DrawingArea

Whenever i tries to create an object of Gtk::Drawarea myArea,application is crashing.

In the C library, there’s a GtkDrawingArea, but no GtkDrawarea. Are you just shortening the name? or are you talking about something else? Are the C++ bindings doing weird stuff here?

Gtk::DrawingArea in gtkmm-3.22

I wanted to draw Straight Lines without override class method on_draw().

I want to use my own function to draw instaed of using signal function on_draw().

please help me on this

In the C API, there’s no on_draw() method, just a draw signal that you can connect to whatever method you want (the example in the documentation calls it draw_callback()). And that’s how GtkDrawingArea is designed to be used. So I fail a bit to know what you’re trying to do.

Are you subclassing GtkDrawingArea or not? (both can be done.)

No, I am not using subclassing (inhrited )GtkDrawingArea class.

See the below statement when i compile myprogramm it compiled successfully but whenever i tried to run my app then it crashing on below statement.

Gtk::DrawingArea myArea;

Aren’t you connecting the signals before the GtkDrawingArea is created, or something like that?

No, I am not using such kind of signals.

Please look this document link.

Gtkmm Drawingarea

I think it is not allowing for my own signal handler.

please help me by cross verify this.

I’m not knowledgeable at all in Gtk used from C++, but the example application goes with subclassing. Maybe that’d be easier to go that path here, or maybe it’s the only way to go; what’s your goal on using plain GtkDrawingArea instead of subclassing?

Just to reduce code length

@ebassi do you have any idea on this ?

Saying something “is crashing” without showing your code and a backtrace is not really useful.

You’ll have to debug it yourself, since only you have access to that information.

Follow the examples of the documentation of the C++ bindings, and in case you have questions, ask on the gtkmm mailing list.

Additionally, and just as a matter of etiquette: tagging random people just because they answered one of your questions isn’t exactly polite.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.