Development/Tutorials/Introduction to Goya usage

From KDE TechBase
Revision as of 15:34, 13 February 2008 by Ereslibre (talk | contribs)
Introduction to the Goya Framework usage
Tutorial Series   Goya Framework
Previous   C++, Qt, Model/View Qt Framework, KDE4 development environment
What's Next   n/a
Further Reading   n/a

Abstract

We are developing some component of our application using Model/View (check prerequisites). At some point on our development, we discover that we actually want to add widgets to our delegate, but the Model/View framework does not provide a powerful and integrated way of doing so. Here is where Goya comes to help out for this task.

We could say Goya is a layer between the view and your delegate that draws widgets with the needed options and that seem to behave as if they were real widgets, but they are fake widgets after all.

Goya is so nice mainly because it integrates pretty well with the Model/View design, and uses the Qt powerful signals and slots. Goya widgets will emit signals when something have happened to them, so you will be able to connect those signals to your app slots, and do fancy stuff without complex stuff.

A Simple Example

// Basic Goya includes

  1. include <goya/goya.h>
  2. include <goya/pushbutton.h>

// Basic Qt includes

  1. include <QPainter>
  2. include <QBoxLayout>
  3. include <QListView>
  4. include <QStringListModel>

// Basic KDE includes

  1. include <kapplication.h>
  2. include <kaboutdata.h>
  3. include <kmessagebox.h>
  4. include <kcmdlineargs.h>
  5. include <klocalizedstring.h>
  6. include <kicon.h>