开发者

How to make a Widget slide view with Qt4?

开发者 https://www.devze.com 2023-04-03 13:35 出处:网络
I currently display several widgets (quite large ones, almost screen-wide) on a QStackedLayout, let\'s call these widgets \"pages\". Switching from a page to another is done with buttons below (previo

I currently display several widgets (quite large ones, almost screen-wide) on a QStackedLayout, let's call these widgets "pages". Switching from a page to another is done with buttons below (previous, index, next).

I would like pages to slide while switching, as if they were placed on a larger-than-screen row, moving left or right depending on what the user wants.

For this I thought the QScrollArea would be OK, but I can add only one widget to it and I cannot index sub-items to move accordingly nor can I force a per-item-scroll (I don't want the sliding movement to stop between two pages.)

Another option is the QListView or other derivate from QAbstractItemView, but I can't find how to pass a widget as a QListItemModel or other reimplemented QAbstractItemModel. Roles for data are quite limited, and none seem to allow 开发者_开发问答QWidgets.

How can I proceed to achieve this?


It seems using a QScrollArea and scroll programmatically using the inherited scrollContentsBy() would do the trick. The viewport then would be an elongated widget, sliding left or right so one section could be seen at a time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号