I'm trying to implement a QT gui in visual studio, and i've been stuck at this point for a few hours and googling hasn't helped me much. It might be worth adding that i'm only using moc and uic, this isn't made as a QT project.
I have my MainMenu.ui which uic's to ui_MainMenu.h
I have MainMenu.h which moc's to moc_MainMenu.cpp
And I have MainMenu.cpp which contains the methods for the slots.
This all compiles, however at runtime i receive the errors
Object
::connect: No such
slot QMainWindow::menuBarTriggered(QAction*) in c
:\......\src\common\ui_mainmenu.
h:144Object::connect: (sender name: 'menubar')
Object::connect: (receiver name: 'MainMenu')
Object::connect: No such slot QMainWindow::menuBarTriggered(QAction*) in c:\......\src\common\ui_mainmenu.h:144
Object::connect: (sender name: 'menubar')
Object::connect: (receiver name: 'MainMenu')
To copy to clipboard, switch view to plain text mode
for every one of my slots.
The relevant files are
MainMenu.h
#ifndef MAINMENU_H
#define MAINMENU_H
#include <QtCore/QObject>
#include <QObject>
#include <QtGui/QMainWindow>
#include "ui_MainMenu.h"
namespace Ui
{
class MainMenu;
}
{
Q_OBJECT
public:
~MainMenu();
public slots:
void runButtonClicked();
void browseButtonClicked();
void arRadioToggled();
void p2iRadioToggled();
void vfRadioToggled();
private:
Ui::MainMenu *ui;
};
#endif
#ifndef MAINMENU_H
#define MAINMENU_H
#include <QtCore/QObject>
#include <QObject>
#include <QtGui/QMainWindow>
#include "ui_MainMenu.h"
namespace Ui
{
class MainMenu;
}
class MainMenu : public QMainWindow
{
Q_OBJECT
public:
MainMenu(QWidget *parent =0);
~MainMenu();
public slots:
void runButtonClicked();
void browseButtonClicked();
void arRadioToggled();
void p2iRadioToggled();
void vfRadioToggled();
void menuBarTriggered(QAction*);
private:
Ui::MainMenu *ui;
};
#endif
To copy to clipboard, switch view to plain text mode
MainMenu.cpp
#include "MainMenu.h"
#include "ui_MainMenu.h"
#include "moc_MainMenu.cpp"
#include <iostream>
{
ui->setupUi(this);
}
MainMenu::~MainMenu()
{
delete ui;
}
void MainMenu::runButtonClicked()
{
std::cout << "run";
}
void MainMenu::browseButtonClicked()
{
std::cout << "browse";
}
void MainMenu::arRadioToggled()
{
std::cout << "ar";
}
void MainMenu::p2iRadioToggled()
{
std::cout << "p2i";
}
void MainMenu::vfRadioToggled()
{
std::cout << "browse";
}
void MainMenu
::menuBarTriggered(QAction* a
) {
std::cout << "menu";
}
#include "MainMenu.h"
#include "ui_MainMenu.h"
#include "moc_MainMenu.cpp"
#include <iostream>
MainMenu::MainMenu(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainMenu)
{
ui->setupUi(this);
}
MainMenu::~MainMenu()
{
delete ui;
}
void MainMenu::runButtonClicked()
{
std::cout << "run";
}
void MainMenu::browseButtonClicked()
{
std::cout << "browse";
}
void MainMenu::arRadioToggled()
{
std::cout << "ar";
}
void MainMenu::p2iRadioToggled()
{
std::cout << "p2i";
}
void MainMenu::vfRadioToggled()
{
std::cout << "browse";
}
void MainMenu::menuBarTriggered(QAction* a)
{
std::cout << "menu";
}
To copy to clipboard, switch view to plain text mode
If you need the moc output or other files i can post those to.
Thanks
Bookmarks