how to express the absolute path and relative path in window system
I want to show a document like 1.map with qt creator, but it come out that : can't not open the map document. As I know it can perform really well in linux system. does any different between linux and windows to express the path. how? thanks.
Re: how to express the absolute path and relative path in window system
please, post more info, the question are ambiguos.
you cant open the document in linux or windows?
are you using the filedialog to get the file path?
maybe you try to get a hardcoded path file. in this case maybe you are in the wrong directory. try use QDir::currentPath to get the current path.
if only need to know how use the absolute or relative path, read the documentacion for QDir.
Re: how to express the absolute path and relative path in window system
Expressed as C strings, Linux absolute paths are like "/some/directory/tree/file". On Windows the same path would be like "C:\\some\\directory\\tree\\file" where C: is the drive letter. Qt allows you (encourages you) to use forward slashes in its file functions on all platforms, so "C:/some/directory/tree/file" should also work. The manual for QDir is a good read.
If you feed Qt a file name "dufus.map" without an absolute path then it will try to open the file in the current working directory (QDir::currentPath()) which is almost certainly never what you think it is ;)
Was that really your question?
Re: how to express the absolute path and relative path in window system
thinks, although it really didn't solve my problem. I do what you said, it turn out to be the same result, still can't open .map document and can't add icon to the button.
Re: how to express the absolute path and relative path in window system
Quote:
Originally Posted by
cage
still can't open .map document and can't add icon to the button.
Is map a image format? What icon, what Button???
Quote:
I want to show a document like 1.map with qt creator
You mean open a file inside the "editor" or your application which you program with the creator?
Please be more descriptive and if possible show us some code.
2 Attachment(s)
Re: how to express the absolute path and relative path in window system
it is difficult to describe , here I will show the result when qt run in difference system.
that is the result in linux
Attachment 3751
and the result in windows
Attachment 3752
as the .cpp document is too long, i can't posted it here.
Re: how to express the absolute path and relative path in window system
it seems that your paths are really wrong. Just post the code of how you set the image to the toolbuttons on the left and on the top. (Including the part with the relevant path settings.)
1 Attachment(s)
Re: how to express the absolute path and relative path in window system
Quote:
Originally Posted by
Lykurg
it seems that your paths are really wrong. Just post the code of how you set the image to the toolbuttons on the left and on the top. (Including the part with the relevant path settings.)
Here I will show the image I have do with the icon.I have set the path, you can see it from the next part.
(1)Attachment 3755
(2)and the reflect in ui.h. the image are in project's file.
Current_Position_action = new QAction(MainWindow);
Current_Position_action->setObjectName(QString::fromUtf8("Current_Position _action"));
QIcon icon1;
icon1.addPixmap(QPixmap(QString::fromUtf8("image/Current_Position.png")), QIcon::Normal, QIcon::Off);
Current_Position_action->setIcon(icon1);
Distant_Measure_action = new QAction(MainWindow);
that's any wrong with it ? another problem , how can i do with the absolute path in windows system with QT Creator.
Re: how to express the absolute path and relative path in window system
First you can use a resource file then you don't have such problems for the icons. See http://doc.trolltech.com/4.5/resources.html.
Second how looks the directories in windows?
Code:
/path/to/your/app/application.exe
/path/to/your/app/image/Current_Position.png
If so the image should normally be found.