Results 1 to 2 of 2

Thread: problem with namespaces

  1. #1
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face problem with namespaces

    It's been many years since I've written anything in c++ so bear with me. I'm trying to create a namespace for my project that will house all of the global objects and things for the project.

    I have the folling name space set up.

    myapp.h
    -----
    Qt Code:
    1. #include <QtGui>
    2.  
    3. namespace myapp {
    4. QList<QPixmap> statusIcons;
    5. statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledgreen.png")));
    6. statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledyellow.png")));
    7. statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledorange.png")));
    8. statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledred.png")));
    9. }
    To copy to clipboard, switch view to plain text mode 

    I'm accessing it like this:

    frmMain.cpp
    -----
    Qt Code:
    1. void frmMain::setStatus(int status) {
    2. if(status<myapp::statusIcons.count())
    3. statusLight->setPixmap(myapp::statusIcons[status]);
    4. }
    To copy to clipboard, switch view to plain text mode 

    which gives me the following errors:

    ../include/myapp.h:28: error: expected constructor, destructor, or type conversion before ‘.’ token
    ../include/myapp.h:29: error: expected constructor, destructor, or type conversion before ‘.’ token
    ../include/myapp.h:30: error: expected constructor, destructor, or type conversion before ‘.’ token
    ../include/myapp.h:31: error: expected constructor, destructor, or type conversion before ‘.’ token

    I'm guessing that the Qt datatypes aren't available or something inside my namespace, but I'm not really sure how to fix it.

    thanks in advance.
    --Steven

  2. #2
    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: problem with namespaces

    Quote Originally Posted by steve918 View Post
    statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledgreen.png")));
    statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledyellow.png")));
    statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledorange.png")));
    statusIcons.insert(0,QPixmap(QString(":/icons/22/images/nuvola/22x22/ledred.png")));
    You can't put bare code inside namespace, only declarations.

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.