PDA

View Full Version : weird error: expected unqualified-id before '...' token



Denarius
17th February 2009, 13:06
The .ui file:

<ui version="4.0" >
<class>FormOutput</class>
<widget class="QWidget" name="FormOutput" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>252</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<property name="styleSheet" >
<string notr="true" >border: 1 solid black;</string>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QTextBrowser" name="textBrowser" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="html" >
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&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>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

//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:


#ifndef FORMOUTPUT_H_
#define FORMOUTPUT_H_

#include "FormOutput.ui"

class FormOutput : public QWidget, public Ui_FormOutput
{
Q_OBJECT
public:
FormOutput(QWidget* parent = 0, Qt::WFlags flags = 0);
virtual ~FormOutput();

public slots:
void appendError(QString message);
void appendMessage(QString message);
void appendDebugMessage(QString message);
void appendCommand(QString message);

private:
void addTextAtTop(QString message);
};
}
#endif

the .cpp file:

#include "FormOutput.h"


FormOutput::FormOutput(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/) : QWidget(parent, flags)
{
setupUi(this);
}


FormOutput::~FormOutput()
{
}

void FormOutput::addTextAtTop(QString message)
{
QTextCursor cursor = this->textBrowser->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.insertHtml(message + "<br />");
}

void FormOutput::appendMessage(QString message)
{
this->addTextAtTop(".. " + message);
}

void FormOutput::appendDebugMessage(QString message)
{
this->addTextAtTop("<font color=\"grey\"># " + message +"</font>");
}

void FormOutput::appendCommand(QString message)
{
this->addTextAtTop("<font color=\"green\">-> " + message +"</font>");
}

void FormOutput::appendError(QString message)
{
this->addTextAtTop("<font color=\"red\">-> <b>" + message +"</b></font>");
}

}

wysota
17th February 2009, 13:08
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.

Denarius
17th February 2009, 13:15
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.

wysota
17th February 2009, 13:45
You are including the ui file directly in your cpp program.

jpn
17th February 2009, 14:16
How does the .pro file look like? Are you using FORMS variable as suggested in the Qt Designer manual?

Denarius
17th February 2009, 14:18
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.