open dialog
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Sun, 22 Jan 2012 00:36:05 +0100
changeset 3 46b8d9898143
parent 2 71093d26a4de
child 4 1499c414b59e
open dialog
igc.pro
mainwindow.cc
mainwindow.h
--- a/igc.pro	Sat Jan 21 23:52:16 2012 +0100
+++ b/igc.pro	Sun Jan 22 00:36:05 2012 +0100
@@ -2,6 +2,8 @@
 # Automatically generated by qmake (2.01a) Sat Jan 21 23:39:20 2012
 ######################################################################
 
+CONFIG += debug
+
 TEMPLATE = app
 TARGET = 
 DEPENDPATH += .
@@ -9,6 +11,7 @@
 
 UI_DIR = .build/
 OBJECTS_DIR = .build/
+MOC_DIR = .build/
 
 # Input
 HEADERS += mainwindow.h
--- a/mainwindow.cc	Sat Jan 21 23:52:16 2012 +0100
+++ b/mainwindow.cc	Sun Jan 22 00:36:05 2012 +0100
@@ -1,3 +1,6 @@
+#include <QApplication>
+#include <QFileDialog>
+#include <QFileInfo>
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
 
@@ -5,5 +8,22 @@
     : QMainWindow(parent), ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
-    dumpObjectTree();
+    connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+    connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
+    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
 }
+
+void MainWindow::open()
+{
+    currentFile = QFileDialog::getOpenFileName(this,
+	tr("Open IGC file"),
+	"", tr("*.igc"));
+
+    setWindowTitle(QFileInfo(currentFile).baseName());
+    statusBar()->showMessage("opening " + currentFile, 5000);
+}
--- a/mainwindow.h	Sat Jan 21 23:52:16 2012 +0100
+++ b/mainwindow.h	Sun Jan 22 00:36:05 2012 +0100
@@ -7,9 +7,14 @@
 
 class MainWindow : public QMainWindow
 {
+  Q_OBJECT
   public:
    MainWindow(QWidget *parent = 0);
+   ~MainWindow();
+  protected slots:
+   void open();
   private:
+   QString currentFile;
    Ui::MainWindow *ui; 
 };