我可以在 Qt 中设置数据库连接而无需编写代码(就像在 Delphi 中一样)吗?
尽管用 C++ 编写比用 Pascal 编写相对困难,但我确实被 Qt 的多平台支持所吸引。我可以从 Linux 连接到在 Win2003 服务器上运行的 MSSQL 服务器,也可以连接到在 Linux 上运行的 PostGreSQL 服务器。与德尔福相比,这是一个优势。
我正在尝试编写示例程序来习惯 Qt 和 C++。到目前为止,我对布局和信号槽机制感到满意(不过仍然双击按钮来编写事件代码:))。我希望我能像在 Delphi 中一样轻松地在程序中使用 SQL 数据。
有什么方法可以将一些连接对象、DataSource、DBGrid 和 DBNavigator 放入表单中,然后无需编写代码即可继续? (对于某些表单来说,它确实可以节省时间,可以使包含 300 多个表单的项目变得更快)
我希望听到使用 Qt 处理 SQL 服务器数据的人们的意见。
Although it is comparatively hard to write in C++ than in Pascal I'm really attracted by multi-platform support of Qt. I can connect to an MSSQL server running on Win2003 server from Linux or I can connect to a PostGreSQL server running on Linux. That made a plus when comparing with Delphi.
I'm trying to write sample programs to get used to the Qt and C++. So far I'm comfortable with the layouts and signals-and-slots mechanism (still double clicking the buttons to write event code though :) ). I wish I was using the SQL data in my programs as easily as in Delphi.
Is there any way that I can put some connection object, a DataSource, a DBGrid and a DBNavigator on to a form and go on without writing code? (For some forms it is really a time saver, a project with 300+ forms can be made faster)
I would like to hear from people using Qt with data from SQL servers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须编写自己的设计器插件才能实现这一点并使您的小部件不可见,因为 Qt Designer 中不直接支持非 GUI 组件。
然而,在 Qt 中编写显式代码(这确实比大多数其他编程环境少了很多工作)有助于程序保持可读性。具有大量表单和组件的 Delphi 项目往往仅对作者而言是可读的,因为依赖关系经常跨文件跳转。如果您以二进制格式存储表单,那么您无论如何都会迷失,因为您无法以文本方式搜索项目来查找依赖项。
良好的设计可以使您的代码变得更小并且易于阅读,这在任何编程环境中都是必要的,并且使得诸如表单中的不可见组件之类的方面变得不那么重要(尽管您会像我一样在一段时间内会怀念它们)。
所以,不幸的是,你目前只能靠自己了。
You would have to write your own designer plugins to achieve that and make your widgets invisible, as there is no direct support for non gui components in Qt Designer.
However, writing explicit code in Qt (which is really a lot less work than in most other programming environments) helps the program to stay readable. Delphi projects with a lot of forms and components tend to become readable to the author alone, because dependencies jump across files a lot. If you store your forms in binary format, you are lost anyway, because you then cannot search your project textually to find dependencies.
Good design, which causes your code to become small and easily readable is necessary in any programming environment and makes aspects like invisible components in forms less important (though you will miss them for a while to come like I do).
So, unfortunately, you are on your own for the moment.