PDA

View Full Version : signals and slots and menus problem in designer



hollowhead
5th March 2010, 17:31
Having conquered the MDI issue (newbie) I've started to implement menus. I've created these in designer (4.5.2.) which I have used before. I'm having two problems. The first is when I run my program through QDevelop the menus I've created (with the exception of File:New see problem two below) are not present in the debug app but are present in designer.

The second problem is if I set up a signal and slot for the menuaction I have just created in designer the program fails to compile apart from the File:New slot. The error message is for open "src/mainwindowimpl.cpp:22: error: ‘actionOpen’ was not declared in this scope " and yet void open(); is declared in the header file thus



class MainWindowImpl : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT

public:

MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );

private slots:

void updateStatusBar();
void newFile();
void open();

void copy();



and the signals and slots are coded thus



MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
setupUi(this); // required so menus appear

mdiArea = new QMdiArea;
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded );
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setCentralWidget(mdiArea);
setWindowTitle(tr("Spreadsheet"));
//createMdiWindow(); // dumps empty sheet in window
createStatusBar();

// signals and slots on constructor
connect(action_New, SIGNAL(triggered()),this, SLOT(newFile()));
//connect(action_Copy, SIGNAL(triggered()), this, SLOT(copy()));
connect(actionOpen, SIGNAL(triggered()),this, SLOT(open()));
//connect(action_Quit, SIGNAL(triggered()), this, SLOT(close()));


}


I had problems getting new to work (same scoping error) but I changed the QAction *newAction; to
QAction *action_New; in designer it worked. This method has not worked for copy/open etc.

The lack of created menus appearing and the signals/slots problem are related, surely I assume a bug but is there any way round it?

Ta.