Re: Add Gtk::TextView to Gtk::Grid
- From: Kjell Ahlstedt <kjellahlstedt gmail com>
- To: Bill Greene <w h greene gmail com>
- Cc: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: Re: Add Gtk::TextView to Gtk::Grid
- Date: Wed, 5 Oct 2022 18:40:27 +0200
You have declared the TextView as a local variable in the constructor.
It will be deleted when the constructor finishes. You must either
declared it in your window class, like the buttons in
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/grid/examplewindow.h
or create it with Gtk::make_managed() in the constructor, like the button in
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/scrolledwindow/examplewindow.cc
Den 2022-10-05 kl. 17:00, skrev Bill Greene via gtkmm-list:
I am trying to add a TextView instance to a Grid. But when I display
the window, it is
empty. The Grid examples I have seen add buttons to the grid and these
work fine
for me. But I don't understand the difference between adding a button
and adding
a TextView. If anyone can help me with this, I would appreciate it.
Here is my sample code (part of the constructor for my window):
set_child(m_grid);
Gtk::TextView tc;
Glib::RefPtr<Gtk::TextBuffer> tb = Gtk::TextBuffer::create();
std::string msg("cell 1,1");
auto it = tb->insert(tb->begin(), msg);
tc.set_buffer(tb);
m_grid.attach(tc, 0, 0);
m_grid.set_visible();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]