You are not logged in.

1

Friday, July 1st 2005, 8:41pm

migrate proram

Hello everybody..
I have programed i small program in the qt designer.
I want to continue working without the designer. I have now just .cpp, .h files..and no ui.h and ui anymore.
I have compiled and i have no errors.everything sees to work.
but all my icons is not there!What should i do to get the icons?What have i forghoten?


Thanks

2

Friday, July 1st 2005, 8:52pm

if the icons are in the same directory like the files, i have the icons..

but if i copy the exe file in another place, the program work but without the icons.why?
its because i have the non comercial version?

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

3

Friday, July 1st 2005, 9:59pm

Quoted

Originally posted by marioo
but if i copy the exe file in another place, the program work but without the icons.why?

Have you copied those icons too?

This post has been edited 1 times, last edit by "jacek" (Jul 1st 2005, 10:00pm)


4

Friday, July 1st 2005, 10:58pm

no, but if i compile the previews programm created by the designer i can copy the exe where i want without the icons and i have allways the icons...

if i give the program(exe file) to other person its not possible that i have to give allways the icons with..

on have to be able to compile and the exe file have to contains all functions and icons..

  • "impeteperry" is male

Posts: 110

Location: Rhode Island, USA

Occupation: self un-employied

  • Send private message

5

Friday, July 1st 2005, 11:02pm

I have somewhat similar problem. I did the original layout in designer and re-wrote in straight Qt. i have program generated data that I store in sub-directories

Source code

1
2
	k = QDir::currentDirPath();                         
	k.append( "/jobs/" + projectIndex + "/" + f );
I can copy the parent directory along with all the sub-directories to another directory and run the program in a terminal and all is fine, but if I run it from a "konqueror" window, the program run ok, but the program does not see the data in the sub-directories. Is this the same problem? I have copied the sub-directories as you suggested.
a helping hand has more than five fingers

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

6

Friday, July 1st 2005, 11:05pm

Quoted

Originally posted by marioo
on have to be able to compile and the exe file have to contains all functions and icons..

If you add "IMAGES += img1.png ... imgn.png" to your .pro file, qmake will create an image collection that will be compiled into your executable. To access these images you can use QPixmap::fromMimeSource() method.

In Qt4 you can use resource files.

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

7

Friday, July 1st 2005, 11:09pm

Quoted

Originally posted by impeteperry
Is this the same problem?

Similar, you are using the QDir::currentDirPath() method and current dir can be any path in the system --- it just points to the directory from which user has started your program. Try using QApplication::applicationDirPath().

8

Friday, July 1st 2005, 11:09pm

i think thats it! But where have i to code:

Quoted


IMAGES += img1.png ...


in the .pro?

here?

Quoted


######################################################################
# Automatically generated by qmake (1.06c) Fr 1. Jul 21:57:40 2005
######################################################################

TEMPLATE = app
INCLUDEPATH += .

# Input
HEADERS += abfrage.h admineditor.h ergebnisse.h mainwindow.h update.h
IMAGES += img1.png
SOURCES += abfrage.cpp \
admineditor.cpp \
ergebnisse.cpp \
main.cpp \
mainwindow.cpp \
update.cpp


jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

9

Friday, July 1st 2005, 11:12pm

Quoted

Originally posted by marioo
i think thats it! But where have i to code:
...
in the .pro?

Yes. qmake will do everything for you, just remember about using QPixmap::fromMimeSource().

10

Friday, July 1st 2005, 11:15pm

its see to work thanks..
If i give now this exe to another person, i dont have to give the icon too right?

It is important to use QPixmap::fromMimeSource() ??

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

11

Friday, July 1st 2005, 11:20pm

Quoted

Originally posted by marioo
If i give now this exe to another person, i dont have to give the icon too right?

You will give them ;) Only they will be hidden inside your executable --- you won't need any additional files.

Quoted

It is important to use QPixmap::fromMimeSource() ??

You will have to retrieve those icons from the image collection and that's what this method does.

12

Friday, July 1st 2005, 11:27pm

so, i have to put : QPixmap::fromMimeSource() there where i am using the icons? For example in the mainwindow.cpp??

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

13

Friday, July 1st 2005, 11:32pm

Quoted

Originally posted by marioo
so, i have to put : QPixmap::fromMimeSource() there where i am using the icons? For example in the mainwindow.cpp??

Suppose you have img1.png in the image collection, to get it and use in your program your need this:

Source code

1
QPixmap pixmap = QPixmap::fromMimeSource("img1.png");

14

Friday, July 1st 2005, 11:34pm

this was generated by the designer:

Quoted


next_btn = new QPushButton( navegator_gb, "next_btn" );
next_btn->setGeometry( QRect( 270, 16, 24, 24 ) );
next_btn->setIconSet( QIconSet( QPixmap::fromMimeSource( "rightarrow.png" ) ) );

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

15

Friday, July 1st 2005, 11:35pm

Quoted

Originally posted by marioo
this was generated by the designer:

That's what I meant.

16

Friday, July 1st 2005, 11:36pm

ok, thank you for your help..

see you soon!


your friend marioo :]

  • "impeteperry" is male

Posts: 110

Location: Rhode Island, USA

Occupation: self un-employied

  • Send private message

17

Saturday, July 2nd 2005, 3:04am

Thanks Jacek.
I don't know how to implement your suggestion

Source code

1
QApplication::applicationDirPath().
I put <,application.h> in my "dlgmain.cpp" file and changed code as follows

Source code

1
2
3
	k = QApplication::applicationDirPath();
	//k = QDir::currentDirPath();                         
	k.append( "/jobs/" + projectIndex + "/" + f );
and got the error message

Source code

1
dlgmain.cpp:905: error: cannot call member function `QString QApplication::applicationDirPath()' without object
I then put

Source code

1
QApplication myApp = new QApplication( this );
in the "dlgmain.cpp" constructor and revised the code to

Source code

1
2
3
	k = myApp.applicationDirPath();
	//k = QDir::currentDirPath();                         
	k.append( "/jobs/" + projectIndex + "/" + f );
and my error was

Source code

1
2
3
4
5
6
7
usr/lib/qt-3.3/include/qapplication.h:435: note: candidates are: QApplication::QApplication(const QApplication&)
/usr/lib/qt-3.3/include/qapplication.h:81: note:                 QApplication::QApplication(Display*, int,char**, long unsigned int, long unsigned int)
/usr/lib/qt-3.3/include/qapplication.h:79: note:                 QApplication::QApplication(Display*, longunsigned int, long unsigned int)
/usr/lib/qt-3.3/include/qapplication.h:77: note:                 QApplication::QApplication(int&, char**, QApplication::Type)
/usr/lib/qt-3.3/include/qapplication.h:75: note:                 QApplication::QApplication(int&, char**, bool)
/usr/lib/qt-3.3/include/qapplication.h:74: note:                 QApplication::QApplication(int&, char**)
dlgmain.cpp:167: warning: unused variable 'myApp'
ObviouslyI don't know how to implement your suggestion. Do I have to place it in "main.cpp" and to be able to use it in "dlgmain.cpp" and other ".cpp" files? If so what would be the code? This problem has been bothering me for a long time and Marioo's thread got my attention. (Thanks Marioo)
a helping hand has more than five fingers

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

18

Saturday, July 2nd 2005, 7:40am

You could start by reading the docs to see what QApplication parameters are and that you have a global pointer to your QApplication object called qApp, so you should be using qApp->applicationDirPath().

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

19

Saturday, July 2nd 2005, 1:34pm

Quoted

Originally posted by impeteperry
and got the error message

Source code

1
dlgmain.cpp:905: error: cannot call member function `QString QApplication::applicationDirPath()' without object


QApplication::applicationDirPath is not static.
While this notation inside code is usually used for static methods, it is also used in emails or other text conversation media to fully specify a method, i.e. which class it belongs and what it is named.

It is assumed that the read has access to the API docs and can lookup static'ness themselves.

Cheers,
_
Qt/KDE Developer
Debian User

  • "impeteperry" is male

Posts: 110

Location: Rhode Island, USA

Occupation: self un-employied

  • Send private message

20

Sunday, July 3rd 2005, 2:36am

Thanks myota. I shall reall read the Docs more careful in the future, but you have solved my problem!! I copied the sub-directories that carried the generated data and the executable to o "flash" drive. Ran like it should. Again thank you.
a helping hand has more than five fingers