[kgraphviewer-devel] Re: KGraphViewer Widget interface

Gaël (aka Kleag) kleag at free.fr
Thu Oct 28 21:20:07 CEST 2010


Hi Marco,

You're right, there was missing files in the install instructions. I just 
commited a change to trunk to correct that. But it is temporary as library 
headers should be d-objects (with no includes).

Now, the code below create a very simple graph viewer (for a file on my disk!).

Regards,

Gaël
=============
#SimpleGv.h
#ifndef SimpleGv_H
#define SimpleGv_H

#include <QtGui/QMainWindow>

class SimpleGv : public QMainWindow
{
Q_OBJECT
public:
    SimpleGv();
    virtual ~SimpleGv();
};

#endif // SimpleGv_H

=============
#SimpleGv.cpp
#include "SimpleGv.h"

#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QAction>
#include <kactioncollection.h>

#include <kgraphviewer/dotgraphview.h>

SimpleGv::SimpleGv()
{
  KActionCollection* ac = new KActionCollection(this);
  KGraphViewer::DotGraphView* view = new KGraphViewer::DotGraphView(ac, this);
  view->initEmpty();
  setCentralWidget( view );
  QAction* a = new QAction(this);
  a->setText( "Quit" );
  connect(a, SIGNAL(triggered()), SLOT(close()) );
  menuBar()->addMenu( "File" )->addAction( a );
  view->loadLibrary("/home/kleag/ctext.dot");
}

SimpleGv::~SimpleGv()
{}

#include "SimpleGv.moc"

Le lundi 25 octobre 2010 21:59:02, vous avez écrit :
> Hi,
> 
> I am trying to use the library underneath KGraphViewer in a simple
> graph-viewing application.
> On the kde-apps.org website you say:
> 
> [...] the viewer can now be integrated in an application either as a
> plugin (KPart) or as a real widget.
> 
> But I couldn't figure out how to use it as a plain widget.
> The only installed header file is
> "kgraphviewer/kgraphviewer_interface.h", that doesn't seem to contain
> a widget-like interface.
> Are the "DotGraph" and "DotGraphView" interfaces meant to be installed,
> too?
> 
> (I am a complete noob in KDE development)
> 
> Thanks,
> Marco Poletti

-- 
KsirK - a world domination strategy game 
http://techbase.kde.org/Projects/Games/Tactic_and_Strategy/KsirK

KGraphViewer - a GraphViz dot graphs viewer and editor based on a reusable 
part
http://extragear.kde.org/apps/kgraphviewer


More information about the kgraphviewer-devel mailing list