LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-17-2006, 04:32 PM   #1
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
GTK+ "cannot convert `GObject*' to `GtkObject*'" error


I'm trying to learn GTK+ and am trying to write a basic program that has a button in a window and doesn't really do anything exciting.

I'm kinda doing this in a C++ way as well, but that shouldn't matter here.

My code (the relevant bit) looks like this:

Code:
int main(int argc, char *argv[])
{
  gtk_init(&argc, &argv);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);

  GtkWidget *button = gtk_button_new_with_label("Hello world!");
  gtk_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(callback), (gpointer)"button");

  gtk_widget_show(button);

  gtk_widget_show(window);

  gtk_main();

  return 0;
}
The problematic line is in bold. When I try to compile with "g++ filename.cc -ofilename `pkg-config --cflags --libs gtk+-2.0", I get the following error:

filename.cc: In function `int main(int, char**)':
filename.cc:18: error: cannot convert `GObject*' to `GtkObject*' for
argument `1' to `gulong gtk_signal_connect_full(GtkObject*, const gchar*,
void (*)(), void (*)(GtkObject*, void*, unsigned int, GtkArg*), void*, void
(*)(void*), int, int)'

I don't understand, because there's a line that looks almost identical to mine here and that compiles fine . Any ideas?

All help appreciated!
 
Old 02-17-2006, 04:45 PM   #2
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Well, it's been a couple of years since I did any GTK+ programming, but according to the API reference, gtk_signal_connect() takes a GtkObject as the first parameter, whereas you're casting it to a GObject. Plus gtk_signal_connect() has been deprecated, so you shouldn't be using it in the first place. Try changing that to use g_signal_connect() instead and see if that helps.
 
Old 02-17-2006, 04:47 PM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Original Poster
Rep: Reputation: Disabled
Retard (me, not you). I accidentally typed gtk_signal_connect instead of g_signal_connect. Thanks .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK+ with Glade, "PACKAGE" giving me an error? LegendBreath Programming 0 12-29-2005 10:47 AM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM
GTK: pango and atk error while "make" acrao80 Ubuntu 1 05-21-2005 12:59 PM
run "gtk-theme-switch" error? homesp Debian 2 05-16-2005 12:55 AM
Error message-"cannot convert `__gnu_cxx::__normal_iterator" ashwinipahuja Programming 1 05-13-2004 03:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration