Qt - 新的小部件显示不明显?
我来自 Android 开发,他们从当前活动中打开新“活动”的方法似乎合乎逻辑,并且有记录。 Qt 没有。
假设我有确切的“QTabsExample”,并且其中一个选项卡中有一个按钮。单击按钮时,我想删除所有选项卡并打开不同的视图......比方说图像视图。为什么似乎没有一个例子可以说明这一点?请帮忙!
I'm coming from Android development, and their approach to opening a new "activity" from a current one seems logical, and documented. Qt's does not.
Let's say I have the exact "QTabsExample", and inside one of these tabs is a button. On button click, I want to get rid of all the tabs and open a different view...let's say an image view. Why does there not seem to be one example out there for this? Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信在这种情况下您会想要使用 QStackedWidget 。
QStackedWidget
管理许多相同大小的“屏幕”,您可以在这些“屏幕”之间进行切换,每个屏幕都有自己的一组显示小部件和按钮。这是一个 S60 示例,希望它适用于您的情况,但您应该能够找到有关使用QStackedWidget
的更多信息。I believe you would want to use a QStackedWidget in this case. A
QStackedWidget
manages a number of same sized "screens" that you can switch between, each having its own set of display widgets and buttons. Here is an S60 example, hopefully it will apply to your situation but you should be able to find more info on usingQStackedWidget
s.如果您想删除小部件的容器,更好的解决方案是向窗口发送信号,然后窗口将交换主容器,否则如果您尝试从子操作中删除/删除父对象,事情会变得很糟糕方法。
If you want to remove the container of the widget a better solution is to send a signal to the window and the window will then swap the main containers, otherwise things can get nasty if you try to delete / remove the parent object from the child action method.