Results 1 to 6 of 6

Thread: weird error: expected unqualified-id before '...' token

  1. #1
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation weird error: expected unqualified-id before '...' token

    The .ui file:

    xml Code:
    1. <ui version="4.0" >
    2. <class>FormOutput</class>
    3. <widget class="QWidget" name="FormOutput" >
    4. <property name="geometry" >
    5. <rect>
    6. <x>0</x>
    7. <y>0</y>
    8. <width>252</width>
    9. <height>260</height>
    10. </rect>
    11. </property>
    12. <property name="windowTitle" >
    13. <string>Form</string>
    14. </property>
    15. <property name="styleSheet" >
    16. <string notr="true" >border: 1 solid black;</string>
    17. </property>
    18. <layout class="QHBoxLayout" >
    19. <item>
    20. <widget class="QTextBrowser" name="textBrowser" >
    21. <property name="frameShape" >
    22. <enum>QFrame::StyledPanel</enum>
    23. </property>
    24. <property name="html" >
    25. <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
    26. &lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
    27. p, li { white-space: pre-wrap; }
    28. &lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
    29. &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;">.. initialising program..done&lt;/p>&lt;/body>&lt;/html></string>
    30. </property>
    31. </widget>
    32. </item>
    33. </layout>
    34. </widget>
    35. <resources/>
    36. <connections/>
    37. </ui>
    To copy to clipboard, switch view to plain text mode 
    //end of .ui file

    the error message for this piece of code:
    expected unqualified-id before '<' token (line 1 )
    expected unqualified-id before '<' token (line 16)
    expected unqualified-id before '!' token (line 25)
    Multiple markers at this line (refering to line 26)
    - expected constructor, destructor, or type conversion before '>' token
    - 'style' does not name a type
    - 'meta' does not name a type
    Multiple markers at this line (refering to line 28)
    - 'body' does not name a type
    - expected unqualified-id before '/' token
    - expected constructor, destructor, or type conversion before ';' token
    Multiple markers at this line (refering to line 29)
    - 'p' does not name a type
    - expected unqualified-id before '/' token

    My question:
    What I don't understand is, why is it giving an error on line 1 for no apparent reason? It doesn't give me that error on the other .ui files.
    And why does it seem that it doesn't recognize html-code in the html part.
    Does anybody have some clue at what is the problem here?

    Edit: posted the .h and .cpp file now

    the .h file:

    Qt Code:
    1. #ifndef FORMOUTPUT_H_
    2. #define FORMOUTPUT_H_
    3.  
    4. #include "FormOutput.ui"
    5.  
    6. class FormOutput : public QWidget, public Ui_FormOutput
    7. {
    8. Q_OBJECT
    9. public:
    10. FormOutput(QWidget* parent = 0, Qt::WFlags flags = 0);
    11. virtual ~FormOutput();
    12.  
    13. public slots:
    14. void appendError(QString message);
    15. void appendMessage(QString message);
    16. void appendDebugMessage(QString message);
    17. void appendCommand(QString message);
    18.  
    19. private:
    20. void addTextAtTop(QString message);
    21. };
    22. }
    23. #endif
    To copy to clipboard, switch view to plain text mode 
    the .cpp file:

    #include "FormOutput.h"

    Qt Code:
    1. FormOutput::FormOutput(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/) : QWidget(parent, flags)
    2. {
    3. setupUi(this);
    4. }
    5.  
    6.  
    7. FormOutput::~FormOutput()
    8. {
    9. }
    10.  
    11. void FormOutput::addTextAtTop(QString message)
    12. {
    13. QTextCursor cursor = this->textBrowser->textCursor();
    14. cursor.movePosition(QTextCursor::Start);
    15. cursor.insertHtml(message + "<br />");
    16. }
    17.  
    18. void FormOutput::appendMessage(QString message)
    19. {
    20. this->addTextAtTop(".. " + message);
    21. }
    22.  
    23. void FormOutput::appendDebugMessage(QString message)
    24. {
    25. this->addTextAtTop("<font color=\"grey\"># " + message +"</font>");
    26. }
    27.  
    28. void FormOutput::appendCommand(QString message)
    29. {
    30. this->addTextAtTop("<font color=\"green\">-> " + message +"</font>");
    31. }
    32.  
    33. void FormOutput::appendError(QString message)
    34. {
    35. this->addTextAtTop("<font color=\"red\">-> <b>" + message +"</b></font>");
    36. }
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 17th February 2009 at 14:13. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: weird error: expected unqualified-id before '...' token

    What exactly are you doing with that file? What returns those errors? It seems you are trying to feed a C++ compiler (or preprocessor) with an XML file.

  3. #3
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: weird error: expected unqualified-id before '...' token

    Quote Originally Posted by wysota View Post
    What exactly are you doing with that file? What returns those errors? It seems you are trying to feed a C++ compiler (or preprocessor) with an XML file.
    It's used to give the user some output that the program gives. Kinda like a logger.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: weird error: expected unqualified-id before '...' token

    You are including the ui file directly in your cpp program.

  5. #5
    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: weird error: expected unqualified-id before '...' token

    How does the .pro file look like? Are you using FORMS variable as suggested in the Qt Designer manual?
    J-P Nurmi

  6. #6
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: weird error: expected unqualified-id before '...' token

    Quote Originally Posted by wysota View Post
    You are including the ui file directly in your cpp program.
    thanks, I forgot that.
    But it seems I'm not out of the woods yet....
    I'll see if I can fix it first.

Similar Threads

  1. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19

Tags for this Thread

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.