mardi 1 mai 2018

QT simple menu slot function not triggered

Simple QT wigit app, when debugging I click File, SaveAs, and it never stops in foobar() function. At wits end here, thanks in advance.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenu *File = menuBar()->addMenu("&File");
    QAction *saveAsAct = new QAction( "&SaveAs...", this);
    File->addAction(saveAsAct);
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(foobar()));
}


void MainWindow::foobar()
{
    int i  = 1;
}

MainWindow::~MainWindow()
{
    delete ui;
}

Aucun commentaire:

Enregistrer un commentaire