How to fix Qt Error when adding new form

I was trying to add new form UI class form to the Qt and since I'm a newbie ( actually started today) with C++ Qt framwork at this time i got stuck when I tried to add Push button to open new Class Form. it showed this damn error several times.

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl DialogDemo::DialogDemo(class QWidget *)" (??0DialogDemo@@QEAA@PEAVQWidget@@@Z) referenced in function "private: void __cdecl MainWindow::on_btn_cancel_clicked(void)" (?on_btn_cancel_clicked@MainWindow@@AEAAXXZ)
Rebuilding and cleaning the project not worked since I've tried several ways to display that new GUI form.

Solution was simple here i quote stackoverflow answer.


  1. Right click on project > Clean
  2. Right click on project > Run qmake
  3. Right click on project > Build
  4. Run - worked first time

Why it works

The reason this worked is because Run qmake updates your Makefile. For some reason qt is not automatically updating paths when you make changes to your project such as adding or removing files. Running qmake forces qt to update the paths for your project which enables it to find the mainwindow.obj file. You probably could just run qmake and your problem would be solved.


Popular posts from this blog

පොත් කියවීමයි මමයි

Malware Analysis Tools and Resources Collection