0

Qt での開発は初めてで、Qt 4.8.5 に付属する Qt ネットワーク チャットの例をコンパイルしたいと考えています: http://qt-project.org/doc/qt-4.8/network-network-chat.html

私はVS 2012内で作業していますが、VS 2008でコンパイルしています。次のものが含まれています:

C:\Qt\4.8.5\include\Qt;
C:\Qt\4.8.5\include\QtUiTools;
C:\Qt\4.8.5\include;
C:\Qt\4.8.5\include\QtCore;
C:\Qt\4.8.5\include\QtGui;
C:\Qt\4.8.5\include\QtNetwork;
%(AdditionalIncludeDirectories)

コンパイル プロセスで欠けているステップがあるように感じます。おそらく ui_chatdialog.h ファイルを生成する何かですか? 例から欠落している理由がわかりません。また、ダウンロードした Qt バージョン (4.8.5) に付属のファイルには存在しません。

これは私の現在の出力です:

>------ Rebuild All started: Project: QTChatExample, Configuration: Release Win32 ------
1>  chatdialog.cpp
1>c:\users\dustin\documents\qtchatexample\src\chatdialog.h(44): fatal error C1083: Cannot open include file: 'ui_chatdialog.h': No such file or directory
1>  client.cpp
1>  connection.cpp
1>  main.cpp
1>c:\users\dustin\documents\qtchatexample\src\chatdialog.h(44): fatal error C1083: Cannot open include file: 'ui_chatdialog.h': No such file or directory
1>  peermanager.cpp
1>  server.cpp
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
4

1 に答える 1

2

uic を実行して、ui ファイルのヘッダー ファイルを生成する必要があります。

http://qt-project.org/doc/qt-4.8/uic.html

また、シグナルやスロットなどのソース メタオブジェクト コードを生成するには moc が必要です。

http://qt-project.org/doc/qt-4.8/metaobjects.html

これを行う 1 つの方法は、Visual Studio 用の Qt アドオンを使用することです。moc、uic、およびリソース コンパイラを実行するカスタム ビルド ステップを作成することも、これらを実行する QMake または CMake を使用することもできます。

http://qt-project.org/faq/answer/what_is_the_qt_visual_studio_add-in

VS2012 のこの質問にもタグを付けたので、次を追加します。

アドインを使用して Visual Studio 2012 で Qt4 プロジェクトを操作することはできますか?

于 2013-08-28T20:49:56.473 に答える