如何获取 QSqlTableModel 的列名?
我想要类似 QString QSqlTableModel::getColumnName(int col) 的东西。
I would like to have something like QString QSqlTableModel::getColumnName(int col).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 QSqlTableModel 中设置列名别名: 同样
,您可以从 QSqlTableModel 中检索列名别名:
默认情况下,如果您不设置别名,则列名将等于从表元中读取的内容初始化模型时的数据。确保您的部分索引是有效的列索引。请务必为列指定水平方向,为行指定垂直方向。
希望这有帮助。
You can set column name aliases like so in a QSqlTableModel:
So likewise then you can retrieve column name aliases like so from a QSqlTableModel:
By default if you do not set an alias the column name will be the equal to what was read from table meta data when initializing your model. Be sure that your section index is a valid column index. Be sure to specify an Orientation of Horizontal for columns and Vertical for rows.
Hope this helps.
调用setTable()后,可以调用record()方法获取字段信息。
After call setTable(), you can obtain field information calling record() method.