[Qt-interest] Single inheritance approach: problem connecting

Rui Maciel rui.maciel at gmail.com
Fri Nov 6 12:44:04 CET 2009


I've created a basic main window UI through Qt Designer, which has a QAction entry named actionNew located in 
the main window's file->new menu entry and I've followed the single inheritance approach suggested in the 
documentation. The child class's constructor is as follows:

<code>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
        ui.setupUi(this);

        commandLineDockWidget = new CommandLineDockWidget(this);
        this->addDockWidget(static_cast<Qt::DockWidgetArea>(8), commandLineDockWidget);

        // connect signals and slots
        connect(ui.actionNew, Q_SIGNAL(triggered()), this, Q_SLOT(newProject()));
}
</code>

When I build the project, the compiler throws the following error:

<error>
MainWindow.c++: In constructor ‘MainWindow::MainWindow(QWidget*)’:
MainWindow.c++:13: error: ‘triggered’ was not declared in this scope
make: *** [MainWindow.o] Error 1
</error>


The signal triggered() should be already declared, as it's a member/signal of QAction. So, why is this not 
working?


Thanks in advance,
Rui Maciel



More information about the Qt-interest-old mailing list