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:
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
int main(int argc, char* argv[])
{
// Initialize gtkmm and create the main window
Glib::RefPtr app = Gtk::Application::create(argc, argv, "www.lucidarme.me");
Gtk::Window window;
// Start main loop
return app->run(window);
}
If everything is fine, an empty window should appear:
Download

gtkmm project example for Qt Creator 13.98 KB
Excellent.. Thanks very much!