From a94e09ad5c212dd839b4bba166dba496b31212ce Mon Sep 17 00:00:00 2001 From: Amit Chaudhuri Date: Tue, 9 Apr 2013 09:35:44 +0100 Subject: Add a slot to mainwindow but amend to use Q_SLOTS For some reason, 'private slots:' causes a build error but private Q_SLOTS: works. The error was that 'slots' did not name a type and it appeared to be insensitive to whether the Makefile rule for .moc was in its current place or preceeded the rule for .cpp. Add a slot using the connectByName idiom e.g. actionNew connects to slot on_actionNew_triggered(). Use qDebug to show this fires if the menu option is selected. Above to demonstrate how to begin to link menu to code paths. Signed-off-by: Amit Chaudhuri Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 851d1aa1c..d3e5603be 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -2,10 +2,16 @@ #include "ui_mainwindow.h" #include +#include MainWindow::MainWindow() : ui(new Ui::MainWindow()) { ui->setupUi(this); } +void MainWindow::on_actionNew_triggered() +{ + qDebug() << "actionNew"; +} + #include "mainwindow.moc" -- cgit v1.2.3-70-g09d2