如何将 Qt 集成到现有的应用程序开发工作流程中?
我已经使用 Qt 大约一周了,目的是将 Qt 对话框集成到现有应用程序中。我已经从我的 MFC 应用程序中找到了使用基本的 Qt 消息框,例如:
extern "C" __declspec(dllexport) bool showDialog( HWND parent )
{
QWinWidget win( parent );
win.showCentered();
QMessageBox::about( &win, "About QtMfc", "QtMfc Version 1.0\nCopyright (C) 2003" );
return TRUE;
}
我使用 Qt Designer 来创建对话框。我还没弄清楚如何将所有这些部分组合在一起。 Qt Designer 给我留下了一个 .ui 文件。我已经看到我可以使用 uic 将其编译为 .h 文件,但是其他部分(例如 .cpp 文件)在哪里?此外,如果我想将Qt部分编译为dll,并按需加载,那么过程是什么?就上下文而言,现有的应用程序有 1000 个用户可能想要使用的对话框,因此它们都位于根据需要加载的 dll 中,并且这些对话框作为额外的下载来提供,如果您愿意的话,可以将其视为插件,与主程序。
这可能遗漏了很多,所以请提出问题。
谢谢, 丹尼尔
I have been playing with Qt for a week or so, with the aim of integrating Qt dialogs into an existing application. I've figured out use a basic Qt Message box from my MFC application, eg:
extern "C" __declspec(dllexport) bool showDialog( HWND parent )
{
QWinWidget win( parent );
win.showCentered();
QMessageBox::about( &win, "About QtMfc", "QtMfc Version 1.0\nCopyright (C) 2003" );
return TRUE;
}
I've used Qt Designer to create dialog boxes. What I haven't figured out is how to bring all of these pieces together. Qt Designer leaves me with a .ui file. I've seen that I can use uic to compile that to a .h file, but where are the other parts, like .cpp files? Further, if I want to compile the Qt parts to a dll, which are loaded on demand, what is the process for that? To put it into context, the existing application has 1000's of dialogs that the user may want to use, hence they all live in dll's that are loaded as needed and the dialogs come as additional downloads, kind of a plugin if you will, separately from the main program.
This is probably missing a lot, so please bring on the questions.
thanks,
Daniel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取VS 插件,它使 Qt 与 VS 无缝协作。
它将 ui 文件编译成类,然后您可以从代码中调用这些类。您还可以在 C 代码中编写对话框、菜单等。由于它使用尺寸调整器进行布局,因此不需要太多 XY 坐标来管理每个组件的放置。
不过,如果可以的话,我会采取一种大爆炸的方法,用 Qt main 替换 MFC main 并将功能转移过来。 AFAIK MFC 对话框应该在 Qt 应用程序中完美运行。
Get the VS plugin, it makes Qt work seamlessly with VS.
It complies ui files into classes which you then call from your code. You can also write dialogs, menus, etc in your C code. Since it uses sizers for layout there isn't a lot of X-Y coords to manage to place every component.
Although if you can I would go for a big-bang approach of replacing the MFC main with a Qt main and moving the functionality over. AFAIK MFC dialogs should work perfectly well in a Qt app.