Qt QTableView自上而下流程
我有一个使用继承自 QTableView 的控件显示的网格。现在,网格从左到右显示,然后当内容溢出时,它会像这样转到下一行,
-----------
| 1 | 2 | 3 |
|------------
| 4 | | |
|------------
| | | |
-----------
但我希望它首先从上到下,然后当内容溢出时,它应该像这样转到下一行 我主要是一名 .Net 开发人员,对于 .net winforms 控件来说
-----------
| 1 | 4 | |
|------------
| 2 | | |
|------------
| 3 | | |
-----------
这非常简单,但是我如何让 QTableView
来做到这一点?
谢谢
I have a grid that's display using a control that inherits from QTableView. Right now the grid is displayed left-to-right and then as things overflow, it goes to the next row like this
-----------
| 1 | 2 | 3 |
|------------
| 4 | | |
|------------
| | | |
-----------
but I want it to go top-to-bottom first and then as things overflow, it should go to next column like this
-----------
| 1 | 4 | |
|------------
| 2 | | |
|------------
| 3 | | |
-----------
I'm mostly a .Net developer and it's pretty trivial with .net winforms controls, but how do I get QTableView
to do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显示的数据是模型的函数。更改行为的最佳方法是创建一个代理 QAbstractTableModel 来交换行和列。这有多复杂取决于您当前的模型。听起来好像您有一个线性模型,并且视图只是以类似表格的方式呈现它,在这种情况下您可能使用了错误的模型。
如果您确实有线性模型,请考虑使用 QAbstractListModel 和 QListView。然后,QListView 有一个 flow 属性,允许您在 left 之间进行选择- 从右到上和从上到下。
The data displayed is a function of your model. The best way to change the behavior is to create a proxy QAbstractTableModel that swaps the rows and the columns. How complicated this will be will be dependent on your current model. It almost sounds like you have a linear model and that the view just presents it in a table-like fashion in which case you're probably using the wrong model.
If you really do have a linear model, consider using QAbstractListModel and QListView. The QListView then has a flow property that will allow you to choose between left-to-right and top-to-bottom.