[Howto] speed-up a slow gtk_tree_view (GTK3)

posted in: computer | 0


every time, when the model-data inside the GTK_TREE_VIEW is changed/updated, the whole view will be recalculated (e.g. auto-sizing of row height and column width). This behaviour can lead to massive cpu load and time consumption, because the recalculation will be done after every cell update.

solution tips:

  • delete the view-widget, then update/modify the data-model, afterwards recreate the view. (=best solution)
  • don’t add rows to a sorted data-model. Disable sorting, then add rows, afterwards turn on sorting again.
  • set fixed row height and column width:
    • gtk_tree_view_column_set_sizing()
    • gtk_tree_view_column_set_fixed_width()
    • enable gtk_tree_view_set_fixed_height_mode();
    • disable gtk_tree_view_column_autosize()