View Full Version : c++ error
carniolus
June 11th, 2007, 07:39 PM
So I've managed to do a c++ application with Anjuta and glade.
It worked great until I've added some signals (for instance on_button1_clicked).
But when I compile this, I get some errors like:
cannot allocate an object of abstract type 'window1'
because the followingvirtual functions are pure within 'windows1'
virtual void window1_glade::on_button1_clicked()
How can I fix that?
rekahsoft
June 11th, 2007, 10:47 PM
don't make it pure virtual (abstract)..take the "=0" off the end of the function declaration.
btw don't foget to use code tags when posting code ;)
carniolus
June 12th, 2007, 02:03 PM
I tried, but now I get another error:
undefined reference to 'window1_glade::on_button1_clicked()'
duff
June 12th, 2007, 03:07 PM
then write the function.
carniolus
June 12th, 2007, 03:45 PM
// generated 2007/6/12 15:47:53 CEST by someone@-desktop.(none)
// using glademm V2.6.0
//
// DO NOT EDIT THIS FILE ! It was created using
// glade-- /home/user/Projects/hello/hello.glade
// for gtk 2.10.11 and gtkmm 2.10.8
//
// Please modify the corresponding derived classes in ./src/window1.hh and./src/window1.cc
# include <libintl.h>
#ifndef _WINDOW1_GLADE_HH
# define _WINDOW1_GLADE_HH
// Since all your widgets were private I made them all public.
// To differentiate between accessable (e.g. entries, output labels)
// and unaccessible widgets (e.g. static labels, containers)
// you should use the 'visibility' property (only visible in C++ mode)
#if !defined(GLADEMM_DATA)
#define GLADEMM_DATA
#include <gtkmm/accelgroup.h>
class GlademmData
{
Glib::RefPtr<Gtk::AccelGroup> accgrp;
public:
GlademmData(Glib::RefPtr<Gtk::AccelGroup> ag) : accgrp(ag)
{
}
Glib::RefPtr<Gtk::AccelGroup> getAccelGroup()
{ return accgrp;
}
};
#endif //GLADEMM_DATA
#include <gtkmm/window.h>
#include <gtkmm/entry.h>
#include <gtkmm/button.h>
#include <gtkmm/box.h>
class window1_glade : public Gtk::Window
{
GlademmData *gmm_data;
public:
class Gtk::Window * window1;
class Gtk::Entry * textbox;
class Gtk::Button * gumb;
class Gtk::HBox * hbox1;
protected:
window1_glade();
~window1_glade();
private:
virtual void on_button1_clicked() = 0; this is error
};
#endif
so this is my code (a part of it). where shall I put my function?
carniolus
June 13th, 2007, 04:38 PM
Anyone?
PandaGoat
June 13th, 2007, 07:49 PM
Try making it not a virtual function.
carniolus
June 13th, 2007, 07:54 PM
I solved the first error, but I still don't know where to put my function.
This is important for me, because I want to use the correct sintax.
PandaGoat
June 13th, 2007, 09:00 PM
window.h
class window : Gtk::Window
{
public:
window();
~window();
private:
void on_button1_clicked();
}
window.cpp
window::window()
{
// Create window
// Attach
button1.signal_clicked().connect( sigc::ptr_fun( &on_button1_clicked() ) );
}
window::~window()
{
}
window::void on_button1_clicked()
{
cout << "Button1 was clicked! Yay!\n";
}
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.