Skip to content
Snippets Groups Projects
Commit 564ed98a authored by nicolas.bergont's avatar nicolas.bergont
Browse files

Sample improvment

parent aa53013d
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ License along with this library.
#include "QGVScene.h"
#include "QGVScene.h"
#include <QMessageBox>
#include <QMenu>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
......@@ -32,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(_scene, SIGNAL(nodeContextMenu(QGVNode*)), SLOT(nodeContextMenu(QGVNode*)));
connect(_scene, SIGNAL(nodeDoubleClick(QGVNode*)), SLOT(nodeDoubleClick(QGVNode*)));
connect(_scene, SIGNAL(edgeDoubleClick(QGVEdge*)), SLOT(nodeEdgeClick(QGVEdge*)));
}
MainWindow::~MainWindow()
......@@ -43,11 +45,9 @@ void MainWindow::drawGraph()
{
/*
_scene->loadLayout("digraph test{node [style=filled,fillcolor=white];N1 -> N2;N2 -> N3;N3 -> N4;N4 -> N1;}");
connect(_scene, SIGNAL(nodeContextMenu(QGVNode*)), SLOT(nodeContextMenu(QGVNode*)));
connect(_scene, SIGNAL(nodeDoubleClick(QGVNode*)), SLOT(nodeDoubleClick(QGVNode*)));
ui->graphicsView->setScene(_scene);
return;
*/
_scene->clear();
//Configure scene attributes
_scene->setGraphAttribute("label", "DEMO");
......@@ -120,8 +120,6 @@ void MainWindow::nodeContextMenu(QGVNode *node)
{
//Context menu exemple
QMenu menu(node->label());
menu.addSeparator();
menu.addAction(tr("Informations"));
menu.addAction(tr("Options"));
......@@ -132,5 +130,15 @@ void MainWindow::nodeContextMenu(QGVNode *node)
void MainWindow::nodeDoubleClick(QGVNode *node)
{
QMessageBox::information(this, tr("Node double clicked"), tr("Node %1").arg(node->label()));
QMessageBox::information(this, tr("Node"), tr("Node %1").arg(node->label()));
}
void MainWindow::nodeEdgeClick(QGVEdge *edge)
{
QMessageBox::information(this, tr("Edge"), tr("Edge %1").arg(edge->label()));
}
void MainWindow::on_pushButton_clicked()
{
drawGraph();
}
......@@ -32,11 +32,14 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void drawGraph();
private slots:
void drawGraph();
void nodeContextMenu(QGVNode* node);
void nodeDoubleClick(QGVNode* node);
void nodeEdgeClick(QGVEdge *edge);
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
......
......@@ -11,10 +11,17 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>QGV Sample</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Draw</string>
</property>
</widget>
</item>
<item>
<widget class="QGraphicsViewEc" name="graphicsView">
<property name="renderHints">
......@@ -27,25 +34,6 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>817</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
......
......@@ -23,8 +23,6 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;
w.show();
w.drawGraph();
//w.drawGraph();
return a.exec();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment