Results 1 to 19 of 19

Thread: Qt has no dependences?

  1. #1
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Qt has no dependences?

    Hey guys,so today I tried for the first time my Qt application on another computer,which has nothing to do with coding,so it has nor Qt neither c++ installed.


    So,I moved the .exe alone at first and what happened?...
    Lol..first it required some dlls,which is a problem that I know how to solve,but after that,when the app opened and it had no images(that I used as pixmap)...

    So then I moved the images(that were missing) with the .exe then,some of them could work,but still labels double...

    Can anyone help me?
    I need to demonstrate the program to many people,with different Windows!

    Thank ya.

    What to do?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    You need a imageformats folder in the same folder as your .exe, and in that folder you copy the dll's for the image formats you used in the application.

  3. #3
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    Ok,I went to qt/plugins/imageformats.
    Then,I created a new folder in my USB called "program"e,I put there my exe and made another folder(inside "program") called "imageformats" and moved there all the dll's,
    Tried on the other pc and..same thing.

    The background image and button icons won't show.

    I even dragged the backg. image to the .exe,but it still doesn't show...
    Last edited by "BumbleBee"; 30th March 2011 at 12:12.

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    Maybe it's because "hard-coded" paths, or do you use the resource system for images? If you don't then use resources to integrate the necessary images into your application.

  5. #5
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    My code is:
    Qt Code:
    1. QPalette palette;
    2. palette.setBrush(this->backgroundRole(), QBrush(QImage("1.jpg")));
    3. this->setPalette(palette);
    4.  
    5. //And this for the buttons
    6. x->setIcon(QIcon("ex.png"));
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt has no dependences?

    I put there my exe and made another folder(inside "program") called "imageformats" and moved there all the dll's,
    And how does your application know where to find these dlls?
    You have to add the path to your DLL's to the PATH environment variable.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    For a starnge reason it works..lol
    I added
    Qt Code:
    1. QString myPath;
    2. myPath = "./imageformats";
    3. a.addLibraryPath(myPath);
    To copy to clipboard, switch view to plain text mode 

    And all works fine.Thanks guys,you always know the solution

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

    Default Re: Qt has no dependences?

    Does by any chance you have a "imageformats" directory inside your "imageformats" directory?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    @high_flyer, it's the path where Qt plugins are searched, i though that the deployment path for image plugins should be: plugins/imageformats, but that doesn't work, so default behavior seems to be imageformats folder direct in the same folder as application.

    I think the path to where images are stored is not correct, that is why i suggest you use qresource to store images and icons.

    And you don't need all the dll's from Qt_INSTALL/imageformats you need to copy only the dlls for image type you use (example: qjpeg4.dll if you use .jpg files)

    //if you don't use resources, maybe you can recreate the complete path by using QCoreApplication::applicationDirPath() and append the image name to the returned QString (if the images are in the same folder with the .exe file)
    But it's more clear and easy to use resources.

    LE: too late... i write to slow

  10. #10
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    Ok guys thanks I'll try using resources(btw does recource sys require images to be in the same folder with .exe,or they are compiled inside?)!

    And wysota..I didn't understand what you asked...

  11. #11
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    Wysota asked if you don't have something like imageformats\imageformats\qjpeg4.dll? you need to have imageformats\qjpeg4.dll (and of course other dll's for image formats you used in your application)

    And resources are "compiled" inside the application. //see the link i gave you in my second post

  12. #12
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    Quote Originally Posted by Zlatomir View Post
    Wysota asked if you don't have something like imageformats\imageformats\qjpeg4.dll? you need to have imageformats\qjpeg4.dll (and of course other dll's for image formats you used in your application)

    And resources are "compiled" inside the application. //see the link i gave you in my second post
    Oh..ok.
    No I do not have two folders...it's imageformats/qjpeg4.dll

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

    Default Re: Qt has no dependences?

    So this:
    Qt Code:
    1. QString myPath;
    2. myPath = "./imageformats";
    3. a.addLibraryPath(myPath);
    To copy to clipboard, switch view to plain text mode 
    didn't help your app in any way as it's just plain wrong.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    I made a qrc file.
    It looks like this(added prefix and then images):
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/new/prefix1">
    3. <file>1.jpg</file>
    4. <file>ex.png</file>
    5. <file>o.png</file>
    6. <file>icon.png</file>
    7. </qresource>
    8. </RCC>
    To copy to clipboard, switch view to plain text mode 

    Then in .cpp file I call images like this:
    Qt Code:
    1. QPalette palette;
    2. palette.setBrush(this->backgroundRole(), QBrush(QImage("1.jpg")));
    3. this->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

    Then,I save,build and move the exe alone to a removable disk.
    And...It doesn't work.All the images don't show(like if the qrc doesn't exist..).I add the icons to the removable disk(near exe)and it works then...

    In my main.cpp I have this:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "tictactoe.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. TicTacToe w;
    8. w.show();
    9. Q_INIT_RESOURCE(icons); //My qrc file is: icons.qrc
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Please help.
    Last edited by "BumbleBee"; 3rd April 2011 at 19:24.

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

    Default Re: Qt has no dependences?

    You have no "1.jpg" in the qrc file, you only have ":/new/prefix1/1.jpg".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #16
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    Quote Originally Posted by wysota View Post
    You have no "1.jpg" in the qrc file, you only have ":/new/prefix1/1.jpg".
    Sorry what?
    There is a 1.jpg "declared" in the qrc

  17. #17
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    But you have defined a prefix for the images, which means you have to use it (prefix) when accessing the resources.

  18. #18
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: Qt has no dependences?

    Quote Originally Posted by stampede View Post
    But you have defined a prefix for the images, which means you have to use it (prefix) when accessing the resources.
    Removed.Still same effect
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file>1.jpg</file>
    4. <file>ex.png</file>
    5. <file>o.png</file>
    6. <file>icon.png</file>
    7. </qresource>
    8. </RCC>
    To copy to clipboard, switch view to plain text mode 

  19. #19
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt has no dependences?

    How do you access the images ? If you write QImage("1.jpg") you are not referencing the image from resource system, you have to use the colon - QImage(":/1.jpg"). It's written in the resource system documentation.

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.