[PATCH 3/3] Add a slot to mainwindow but amend to use Q_SLOTS
Lubomir I. Ivanov
neolit123 at gmail.com
Tue Apr 9 02:40:44 PDT 2013
On 9 April 2013 11:35, <amit.k.chaudhuri at gmail.com> wrote:
> From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
>
> 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 <amit.k.chaudhuri at gmail.com>
> ---
> qt-ui/mainwindow.cpp | 6 ++++++
> qt-ui/mainwindow.h | 13 ++++++++++---
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
> index 851d1aa..d3e5603 100644
> --- a/qt-ui/mainwindow.cpp
> +++ b/qt-ui/mainwindow.cpp
> @@ -2,10 +2,16 @@
> #include "ui_mainwindow.h"
>
> #include <QVBoxLayout>
> +#include <QtDebug>
>
> MainWindow::MainWindow() : ui(new Ui::MainWindow())
> {
> ui->setupUi(this);
> }
>
> +void MainWindow::on_actionNew_triggered()
> +{
> + qDebug() << "actionNew";
> +}
> +
> #include "mainwindow.moc"
> diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
> index 9e15e58..6361870 100644
> --- a/qt-ui/mainwindow.h
> +++ b/qt-ui/mainwindow.h
> @@ -3,6 +3,7 @@
>
> #include <QMainWindow>
>
> +
> namespace Ui
> {
> class MainWindow;
> @@ -13,12 +14,18 @@ class DiveNotes;
> class Stats;
> class Equipment;
>
> -class MainWindow : public QMainWindow{
> - Q_OBJECT
> +class MainWindow : public QMainWindow
> +{
> +Q_OBJECT
> public:
> MainWindow();
> +
> +private Q_SLOTS:
hmm, the moc savvy folks, will have to clarify if the usage of
QT_NO_KEYWORDS is preferred.
e.g. Q_SLOTS / slots.
lubomir
--
More information about the subsurface
mailing list