0
votes

How can I make multiple Ui forms in Qt Creator and link them? I want to have a button in my mainwindow.ui and when it's triggered i want the other ui be shown. how can I do it?

I have two Qt Form Classes:

  1. mainwindow
  2. mainwindow2

I tried this code in main.cpp:

#include "mainwindow.h"
#include "mainwindow2.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
MainWindow2 w2;
w2.show();

return a.exec();
}

but this errors occur:

main.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __thiscall MainWindow2::~MainWindow2(void)" (??1MainWindow2@@UAE@XZ) referenced in function _main

main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall MainWindow2::MainWindow2(class QWidget *)" (??0MainWindow2@@QAE@PAVQWidget@@@Z) referenced in function _main

release\testtest.exe:-1: error: LNK1120: 2 unresolved externals

1
Did you define the constructor and the destructor in your MainWindow2 class?thuga

1 Answers

-1
votes

take a look to slots and play with otherUI.show() / otherUI.hide() if you want basics interactions.

For the liker problem : From msdn and here

When you created the project, you made the wrong choice of application type. When asked whether your project was a console application or a windows application or a DLL or a static library, you made the wrong chose windows application (wrong choice).

Go back, start over again, go to File -> New -> Project -> Win32 Console Application -> name your app -> click next -> click application settings.

For the application type, make sure Console Application is selected (this step is the vital step).

The main for a windows application is called WinMain, for a DLL is called DllMain, for a .NET application is called Main(cli::array ^), and a static library doesn't have a main. Only in a console app is main called main