2013-10-24 5 views
0

Qt Creator에서 여러 Ui 폼을 만들고 링크하려면 어떻게해야합니까? 내 메인 윈도우에 버튼이 있고 싶습니다.이 버튼이 트리거되면 다른 버튼이 표시되기를 원합니다. 어떻게 할 수 있습니까?Qt 프로젝트의 다중 Ui

  1. MainWindow를

  • mainwindow2
  • 내가 MAIN.CPP에서이 코드를 시도 :

    나는 두 Qt는 양식 클래스가

    #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(); 
    } 
    

    을하지만,이 오류가 발생합니다

    main.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __thiscall MainWindow2::~MainWindow2(void)" ([email protected]@[email protected]) referenced in function _main

    main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall MainWindow2::MainWindow2(class QWidget *)" ([email protected]@[email protected]@@@Z) referenced in function _main

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

    +0

    는 HTH http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html – Tab

    +2

    당신은 정의나요 다음 liker 문제에 대한

    생성자와 소멸자는'MainWindow2' 클래스에 있나요? – thuga

    답변

    -1

    slots을 살펴보고 기본 상호 작용을 원할 경우 otherUI.show()/otherUI.hide()를 사용하십시오. msdn에서와 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

    +0

    어떻게 다른 UI를 추가하고 사용할 수 있습니까? 나는 "Qt Designer Form Class"와 "Qt Designer Form"을 추가하려고 시도했지만, 어떻게 정의 할 지 모르겠습니다. 클래스 형식에서는 otherui를 표시하려했지만 링크 오류가 발생했습니다. –

    +0

    다른 클래스를 추가하여 main.cpp에 표시하려고 시도했지만 다시 링크 오류가 발생했습니다 –

    +0

    @ Aidin.T 오류? 귀하의 질문에 추가하고 가능한 경우 약간의 코드를 추가하십시오. –