November 25, 2011

hirumon hirumon
Lab Rat
2 posts

Unresolved externals when building using custom widget

 

Hi,
I am new to QT Qt programming.. I wanted to try creating a custom widget..
I created a sample one which just shows a rectangle using paintEvent function..
I added the control to Qt designer.. and it shows up fine..

The problem im facing is that when i tried created a test app by just adding the custom contol..when i build it the following error comes.. I have added the lib fies to the project properties.. still this comes.. pls help me..

  1. Error 2 error LNK2019: unresolved external symbol "public: __thiscall CustomWgtApp::CustomWgtApp(class QWidget *)" (??0CustomWgtApp@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_TestAppClass::setupUi(class QMainWindow *)" (?setupUi@Ui_TestAppClass@@QAEXPAVQMainWindow@@@Z) C:\Users\Bhadran\Documents\Visual Studio 2010\Projects\CustomWgtApp\TestApp\testapp.obj TestApp

  1. Error 3 error LNK1120: 1 unresolved externals C:\Users\Bhadran\Documents\Visual Studio 2010\Projects\CustomWgtApp\\TestApp.exe TestApp

3 replies

November 25, 2011

Volker Volker
Ant Farmer
5331 posts

you need to incorporate the object code of your custom widget. Either by linking it as a library or by adding the source files to your project.

The Designer plugin does not add the code for you, it just makes it available in the graphical design tool.

November 28, 2011

hirumon hirumon
Lab Rat
2 posts

Thank you for your reply.. I have tried linking the lib file also.. Still the problem persists..

November 28, 2011

hirumon hirumon
Lab Rat
2 posts

It works when adding source files to my app.. Must be some problem with the way i created lib file i guess..

 
  ‹‹ Restricting a movable QGraphicsRectItem in the Scene Rect      How to check an eventfilter is installed or not? ››

You must log in to post a reply. Not a member yet? Register here!