PDA

View Full Version : error: 'QDesktopServices' has not been declared



ucomesdag
24th November 2006, 05:04
Worked before and now it seems broken I don't know how to resolve this got any clue?:confused:

mainWindow.cpp: In member function 'void mainWindow::homepage()':
mainWindow.cpp:123: error: 'QDesktopServices' has not been declared
mainWindow.cpp:123: error: invalid type in declaration before '(' token
mainWindow.cpp:123: error: cannot convert 'QUrl' to 'int' in initialization
mainWindow.cpp:123: warning: unused variable 'openUrl'


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QWidget>
#include <QMenuBar>

class mainWindow : public QWidget
{
Q_OBJECT

public:
mainWindow(QWidget *parent = 0);
~mainWindow();
void createMenu();

public slots:
void homepage();

private:
QMenuBar *menuBar;
QMenu *fileMenu;
QAction *openAction;
QAction *saveAction;
QAction *saveAsAction;
QAction *exitAction;
};


#include <QLayout>
#include <QDesktopServices>
#include <QUrl>
#include "mainWindow.h"
#include "floorBoard.h"

mainWindow::mainWindow(QWidget *parent)
: QWidget(parent)
{
createMenu();

floorBoard *fxsBoard = new floorBoard(this);

QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMenuBar(menuBar);
mainLayout->addWidget(fxsBoard);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(mainLayout);
};

mainWindow::~mainWindow()
{

};

void mainWindow::createMenu()
{
menuBar = new QMenuBar;

QMenu *fileMenu = new QMenu("&File", this);
QAction *openAction = fileMenu->addAction("&Open File...");
QAction *saveAction = fileMenu->addAction("&Save");
QAction *saveAsAction = fileMenu->addAction("Save &As...");
fileMenu->addSeparator();
QAction *exitAction = fileMenu->addAction("E&xit");
menuBar->addMenu(fileMenu);

QMenu *helpMenu = new QMenu("&Help", this);
QAction *homepageAction = helpMenu->addAction(" &Webpage");
menuBar->addMenu(helpMenu);

connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(homepageAction, SIGNAL(triggered()), this, SLOT(homepage()));

};

void mainWindow::homepage()
{
QDesktopServices::openUrl(QUrl("http://www.google.com/"));
};

munna
24th November 2006, 05:34
Does your include path contains the path to QDesktopServices ?

ucomesdag
24th November 2006, 05:48
Yes it is...

munna
24th November 2006, 05:56
Is it QDesktopServices or QDesktopService ?

I think it is QDesktopService

jacek
24th November 2006, 10:07
mainWindow.cpp: In member function 'void mainWindow::homepage()':
mainWindow.cpp:123: error: 'QDesktopServices' has not been declared
mainWindow.cpp:123: error: invalid type in declaration before '(' token
mainWindow.cpp:123: error: cannot convert 'QUrl' to 'int' in initialization
mainWindow.cpp:123: warning: unused variable 'openUrl'
Are these the first errors you get? Do you have more than one Qt version installed on your system?

ucomesdag
24th November 2006, 12:19
These are the first errors I get and the only

ucomesdag
24th November 2006, 14:55
Does your include path contains the path to QDesktopServices ?

Found the problem somehow I managed to downgrade from 4.2.1 to 4.1 on linux.. oups...:o

jpn
24th November 2006, 15:36
That's weird if it really didn't say anything about the missing header included.