Results 1 to 8 of 8

Thread: error: 'QDesktopServices' has not been declared

  1. #1
    ucomesdag Guest

    Exclamation error: 'QDesktopServices' has not been declared

    Worked before and now it seems broken I don't know how to resolve this got any clue?

    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'

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QWidget>
    5. #include <QMenuBar>
    6.  
    7. class mainWindow : public QWidget
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. mainWindow(QWidget *parent = 0);
    13. ~mainWindow();
    14. void createMenu();
    15.  
    16. public slots:
    17. void homepage();
    18.  
    19. private:
    20. QMenuBar *menuBar;
    21. QMenu *fileMenu;
    22. QAction *openAction;
    23. QAction *saveAction;
    24. QAction *saveAsAction;
    25. QAction *exitAction;
    26. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <QLayout>
    2. #include <QDesktopServices>
    3. #include <QUrl>
    4. #include "mainWindow.h"
    5. #include "floorBoard.h"
    6.  
    7. mainWindow::mainWindow(QWidget *parent)
    8. : QWidget(parent)
    9. {
    10. createMenu();
    11.  
    12. floorBoard *fxsBoard = new floorBoard(this);
    13.  
    14. QVBoxLayout *mainLayout = new QVBoxLayout;
    15. mainLayout->setMenuBar(menuBar);
    16. mainLayout->addWidget(fxsBoard);
    17. mainLayout->setMargin(0);
    18. mainLayout->setSpacing(0);
    19. mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    20. setLayout(mainLayout);
    21. };
    22.  
    23. mainWindow::~mainWindow()
    24. {
    25.  
    26. };
    27.  
    28. void mainWindow::createMenu()
    29. {
    30. menuBar = new QMenuBar;
    31.  
    32. QMenu *fileMenu = new QMenu("&File", this);
    33. QAction *openAction = fileMenu->addAction("&Open File...");
    34. QAction *saveAction = fileMenu->addAction("&Save");
    35. QAction *saveAsAction = fileMenu->addAction("Save &As...");
    36. fileMenu->addSeparator();
    37. QAction *exitAction = fileMenu->addAction("E&xit");
    38. menuBar->addMenu(fileMenu);
    39.  
    40. QMenu *helpMenu = new QMenu("&Help", this);
    41. QAction *homepageAction = helpMenu->addAction(" &Webpage");
    42. menuBar->addMenu(helpMenu);
    43.  
    44. connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
    45. connect(homepageAction, SIGNAL(triggered()), this, SLOT(homepage()));
    46.  
    47. };
    48.  
    49. void mainWindow::homepage()
    50. {
    51. QDesktopServices::openUrl(QUrl("http://www.google.com/"));
    52. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: 'QDesktopServices' has not been declared

    Does your include path contains the path to QDesktopServices ?

  3. The following user says thank you to munna for this useful post:


  4. #3
    ucomesdag Guest

    Default Re: error: 'QDesktopServices' has not been declared

    Yes it is...

  5. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: 'QDesktopServices' has not been declared

    Is it QDesktopServices or QDesktopService ?

    I think it is QDesktopService

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: 'QDesktopServices' has not been declared

    Quote Originally Posted by ucomesdag View Post
    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?

  7. #6
    ucomesdag Guest

    Default Re: error: 'QDesktopServices' has not been declared

    These are the first errors I get and the only

  8. #7
    ucomesdag Guest

    Default Re: error: 'QDesktopServices' has not been declared

    Quote Originally Posted by munna View Post
    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...

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: 'QDesktopServices' has not been declared

    That's weird if it really didn't say anything about the missing header included.
    J-P Nurmi

Similar Threads

  1. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11
  2. Replies: 2
    Last Post: 25th March 2006, 14:21
  3. Fed up with M$ Window$ !!! Why is Tux leaving me alone???
    By fullmetalcoder in forum General Discussion
    Replies: 35
    Last Post: 18th March 2006, 12:57
  4. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54
  5. Qt 4.1 and KDE 3.5.1 on OSX 10.2.8
    By Ptero-4 in forum Installation and Deployment
    Replies: 6
    Last Post: 6th February 2006, 02:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.