Re: gtk_box_pack: assertion `child->parent == NULL
- From: Yann LEYDIER <yann leydier info>
- To: gtkmm-list gnome org
- Subject: Re: gtk_box_pack: assertion `child->parent == NULL
- Date: Fri, 11 Feb 2011 21:49:51 +0100
As menus can popup, I would expect them to be attached to some kind of
window and therefore to have a parent, thus the failed assertion…
Maybe you could try to simulate a menu with buttons (calling
but.set_relief(Gtk::RELIEF_NONE)) or a treeview (calling
tv.set_hover_selection(true)) ?
On 10/02/11 19:27, cppgangster wrote:
Hi I am trying to put Gtk::menu to Gtk:Vbox container, when I run it, I get
exception throw with msg "(main:14565): Gtk-CRITICAL **: gtk_box_pack:
assertion `child->parent == NULL' failed"
And here is my code:
/*
* File: newfile.hpp
* Author: cppguy
*
* Created on 10 February 2011, 06:44
*/
#ifndef NEWFILE_HPP
#define NEWFILE_HPP
#include "gtkmm-2.4/gtkmm/window.h"
#include<gtkmm-2.4/gtkmm/menu.h>
#include<gtkmm-2.4/gtkmm/label.h>
#include "gtkmm/scale.h"
#include "gtkmm/box.h"
class window:public Gtk::Window{
private:
Gtk::Menu menu1;
Gtk::Label label1;
Gtk::HScale hscale1;
Gtk::HBox hbox1;
Gtk::VBox vbox1;
public:
window();
~window();
void on_menu_posission(Gtk::PositionType);
};
#endif /* NEWFILE_HPP */
#include<gtkmm-2.4/gtkmm/action.h>
#include<gtkmm-2.4/gtkmm/adjustment.h>
#include "newfile.hpp"
#include "gtkmm/menuitem.h"
window::window():
label1("Pasirinkite is saraso: "),
hscale1(0.0,10.0,0.5),
hbox1(false,5),
vbox1(false,5)
{
set_title("Menu");
Gtk::MenuItem* item=Gtk::manage(new Gtk::MenuItem("Apatinis"));
item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this,
&window::on_menu_posission),Gtk::POS_BOTTOM));
menu1.append(*item);
item=Gtk::manage(new Gtk::MenuItem("Virsutinis"));
item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this,
&window::on_menu_posission),Gtk::POS_TOP));
menu1.append(*item);
add(hbox1);
hbox1.set_border_width(10);
vbox1.set_border_width(5);
hbox1.pack_start(vbox1);
vbox1.pack_start(label1);
vbox1.pack_start(hscale1);
hbox1.pack_start(menu1);
show_all_children();
}
window::~window(){}
void window::on_menu_posission(Gtk::PositionType pos){
hscale1.set_value_pos(pos);
}
/*
* File: main.cpp
* Author: cppguy
*
* Created on 10 February 2011, 06:40
*/
#include<cstdlib>
#include "gtkmm/main.h"
#include "newfile.hpp"
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
Gtk::Main m(argc,argv);
window win;
Gtk::Main::run(win);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]