Question

I'm writing a program using gtkmm-2.4 GUI package in Linux. How can I set a text column of a TreeView object to perform word wrapping in C++?

Was it helpful?

Solution

Ahh, the strange and delightful word of GTK's CellRenderers.

#include <pangomm/layout.h>

// say we want to wrap the 3rd column in our treeview
int colNum = 3;
Gtk::CellRendererText* pCellRendererText = dynamic_cast<Gtk::CellRendererText*>(pTreeView->get_column_cell_renderer(colNum));
pCellRendererText->property_wrap_mode() = Pango::WRAP_WORD;
pCellRendererText->property_wrap_width() = 20;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top