gtkmm and Qt Creator

This is part of a more general work dedicated to gtkmm accessible here. The aim of this post is to explain how to use the C++ wrapper for GTK+ (gtkmm) with the Qt Creator IDE. This configuration has been done with the following software versions :
  • Ubuntu 14.04 LTS (and 12.04 LTS)
  • Qt Creator 3.0.1
  • gtkmm 3

Package installation

First, install Qt creator if it is not done yet:

sudo apt-get install qtcreator

Now install the GTK+ developpment package:

sudo apt-get install libgtkmm-3.0-dev

Project configuration

Create a new Qt Application Console:

Capture du 2014-12-04 11:35:53

Once, the project is created, edit the project file (.pro) and disable Qt libraries (QT-=gui and QT-=core). Add the following lines to use the gtkmm libraries

unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += gtkmm-3.0

Your project file should look like this:

# Disable Qt core and Qt Graphical user interface (don't use Qt)
QT	    -= core
QT	    -= gui

# Name of the target (executable file)
TARGET	    = gtkmm_test

# This is a console application
CONFIG	    += console
CONFIG	    -= app_bundle

# This is an application
TEMPLATE    = app

# Sources files
SOURCES	    += main.cpp

# GTK+ library
unix: CONFIG	+= link_pkgconfig
unix: PKGCONFIG += gtkmm+-3.0

Copy and past this simple example in the file main.cpp, build and run the application.

// Include gtkmm library
#include <gtkmm.h>

int main(int argc, char* argv[])
    // Initialize gtkmm and create the main window
    Glib::RefPtr app = Gtk::Application::create(argc, argv, "");
    Gtk::Window window;
    // Start main loop
    return app->run(window);

If everything is fine, an empty window should appear:
Screenshot from 2014-12-05 18:34:55


3 thoughts on “gtkmm and Qt Creator

  1. there are no includes file. What is a valid path to this library on rasperry pi 2b raspian 32 bit version . I use gtkmm version 3 and Qt 5 defoult kit.

Leave a Reply

Your email address will not be published. Required fields are marked *