PDA

View Full Version : Some problems



Dante
10th July 2009, 12:06
Hi
I'm learning Qt from its,as I heard,official book.But I have problems with two of its examples.
1-This with the find Dialog example.I wrote exactly what was written in the book.But after making,I understood that the layout direction is right to left.As you may know,this example doesn't have a .ui file that I can modify it to change the layout direction.What is the problem and the solution?
2-This one is with the cell location dialog example.Again I did exactly everything that was written in the book.But after making it,there was two errors.The strange thing about the errors was this that they were complaining about the XML code in the .ui file.The errors are:

expected unqualified-id before '<?' token
'Cell' does not name a type
They are respectively for the lines below:


<?xml version="1.0" encoding="UTF-8"?>
<string>&amp;Cell Location</string>

thanks

jpn
16th July 2009, 17:51
Are you trying to compile an XML file with a C++ compiler or what?

Dante
17th July 2009, 11:48
No.I just run make on my project and I got these messages.I if I tried to compile the XML file with the C++ compiler I would take hundred lines of error.

jpn
17th July 2009, 11:55
So where does this error:


expected unqualified-id before '<?' token
'Cell' does not name a type

come from? Could you paste a bit more, including the last command what was run etc?

EDIT: And what does your .pro file look like?

Dante
17th July 2009, 19:55
This is my .pro file

################################################## ####################
# Automatically generated by qmake (2.01a) ???? ????? 10 13:44:15 2009
################################################## ####################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += ui_gotocelldialog.h
FORMS += gotocelldialog.ui
SOURCES += main.cpp

wysota
17th July 2009, 21:01
Remove the file from HEADERS, it shouldn't be there. Anyway your first post suggests you did try to compile an xml file with c++ compiler - it broke on the <?xml token and tried to recover by moving to the next statement (after the semicolon) and immediately broke again on "Cell".

Dante
18th July 2009, 17:09
I didn't write that.anyway I changed it but there was no difference.when I remove and run qmake on it,it adds that line again and the make gives the same error.I even deleted that line and run make on it but there was still the same problem.

wysota
19th July 2009, 22:05
No, you run "qmake -project", not qmake. Remove the line and run qmake.

Dante
20th July 2009, 09:32
No difference

spirit
20th July 2009, 09:45
could you attach whole project that we can try to build?

wysota
20th July 2009, 09:52
No difference

You mean it still adds something to the HEADERS variable? :)

Dante
20th July 2009, 13:42
No.it adds nothing but gives the same errors.
And here's the project.

spirit
20th July 2009, 13:54
jpn was right, you compile a xml file


#include "gotocelldialog.ui"//ui has xml structure!!

try this


#include "ui_gotocelldialog.h"


I don't know your code will work at all.
looks like you still don't want to read docs about Qt and even more -- about C++!

this is correct code


#include <QApplication>
#include <QDialog>

#include "ui_gotocelldialog.h"

int main(int argc,char *argv[]){
QApplication app(argc,argv);

Ui::GoToCellDialog ui;
QDialog dialog;
ui.setupUi(&dialog);

return dialog.exec();
}

Dante
20th July 2009, 15:38
Corrected.
thanks