Forum

Results 1 to 10 of 10

Thread: Qt Window Icon

  1. #1
    Join Date
    January 2017
    Location
    Germany
    Posts
    26

    Qt Window Icon

    Hey, when i try to set the WindowIcon of my GUI, i get the following error:
    Code:
    settings_qt.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl QIcon::~QIcon(void)" ([email protected]@[email protected])
    settings_qt.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl QIcon::QIcon(class QString const &)" ([email protected]@[email protected]@@@Z)

    This is what i am trying to do:
    Code:
    QIcon icon = QIcon(":/icons/img/icon.png");
    	setWindowIcon(icon);
    Anybody know how to fix this?
    Thanks, CubE135.

  2. #2
    Join Date
    January 2017
    Location
    Germany
    Posts
    26
    Anyone got an idea?

  3. #3
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Just some shots in the dark:

    Do you link with the Qt gui library (as QIcon is part of it)?
    =>
    Code:
    QT *= gui
    in your project file if you are using qmake to build.

    Are the Qt libraries built with another toolchain (different versions of MSVC)?
    Did you built them yourselve or did you download the prebuilt ones?

  4. #4
    Join Date
    January 2017
    Location
    Germany
    Posts
    26
    Hey, im actually using Visual Studio to build the project.
    I can even include the Gui Module like this:
    Code:
    #include <QtGui/QtGui>
    But if i try to use the QIcon class, i get the error above.

  5. #5
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    You did not answer any of my questions.

    My guess is that your Qt libs are not built with the same toolchain you are building your project with (compiler, not same architecture, MSVC version, ...).

    Posting your .pro file might help as well.

  6. #6
    Join Date
    January 2017
    Location
    Germany
    Posts
    26
    Hey, im sorry i have misunderstood your questions.
    I do not actually have a .pro file as i integrated my Qt into my Visual Studio Project following this Tutorial: https://github.com/Cloudbreaker-Plug...Qt-Gui-Example

  7. #7
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    I see. Imho this is (especially for starters using the Qt framework) way too complicated.

    All the "Qt magic" (like invoking moc and uic) is made manually, so doing wrong can lead to unneeded errors.


    This does not directly help, but I would suggest using either Qt Creator instead of Visual Studio (which is imho the best IDE for C/C++ projects) or to use this addin for Visual Studio. Both ways, you just need to configure the path to your qt libraries (if not detected automatically), and do "the magic stuff" for you, so you can concentrate on your programming logic.

    But apart from that: generally speaking, something is wrong with your Qt (gui) library not linking correctly.

  8. #8
    Join Date
    January 2017
    Location
    Germany
    Posts
    26
    Hey, im already using the addin you linked
    I just checked the Qt lib directory and there is no seperate lib file for the Gui components.

  9. #9
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Then back to these questions:
    Quote Originally Posted by Thomas View Post
    Are the Qt libraries built with another toolchain (different versions of MSVC)?
    Did you built them yourselve or did you download the prebuilt ones?
    If you use the Visual Studio Addin, I suggest to not follow the tutorial you linked, because the addin will do the additional work for you.
    If you didn't create your project with the addin (New Project -> "Qt project something"), I recommend starting fresh with it (the tutorial only states "Create a new Visual Studio Solution").

  10. #10
    Join Date
    January 2017
    Location
    Germany
    Posts
    26
    So, it works now.
    The solution in my case:
    Code:
    #pragma comment (lib, "Qt5Gui")
    More general solution: Start off using the Visual Studio Addin to create the Project in the first place. (New Project -> "Qt ...")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: June 6th, 2017, 11:03 PM
  2. i_icon_id browse icon window can not open
    By specialo in forum Permission System
    Replies: 3
    Last Post: November 5th, 2011, 02:39 PM
  3. No window, only process and tray-icon
    By ghost0cnc in forum Windows
    Replies: 0
    Last Post: February 28th, 2010, 02:02 PM
  4. Console window minimized to taskbar icon?
    By gary231178 in forum General Questions
    Replies: 0
    Last Post: December 22nd, 2009, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •