Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望添加导航控件 #15

Closed
Cheukfung opened this issue Mar 6, 2023 · 19 comments
Closed

希望添加导航控件 #15

Cheukfung opened this issue Mar 6, 2023 · 19 comments
Assignees

Comments

@Cheukfung
Copy link
Contributor

Cheukfung commented Mar 6, 2023

目前我的做法是用listwidget配合stackedwidget,首先在qlistwidget设置好图标和文字,然后给定一个宽度,比如200px,然后切换的时候,把这个宽度设置为50px,就有类似缩回去的动画;这时候宽度只够显示图标,把滚动条隐藏,就有视频中的效果,但是这个做法比较奇葩,希望作者有更好的实现方法。

2.mp4
@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 7, 2023

等周末有空再试试看吧,我觉得你的方法能用就可以了

@zhiyiYo zhiyiYo self-assigned this Mar 11, 2023
@fsf678
Copy link

fsf678 commented Mar 13, 2023

球球辣,快加导航和图标

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

别急,晚上就推上去

@fsf678
Copy link

fsf678 commented Mar 13, 2023

右上角消息框能搞一些控件在里面吗?我想添加图片、滑块在里面作为一个比较小的音乐播放模块内置在我的应用中?

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

这个你可能得自己写了

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

@Cheukfung
你是怎么让导航部件右边的 QStackedWidget 填满整个界面的,重写主界面 resizeEvent 来调整大小吗?用 QHBoxLayout 的话会有一大片的空白🤔
image

@Cheukfung
Copy link
Contributor Author

Cheukfung commented Mar 13, 2023

@zhiyiYo 用QHBoxLayout,包含 左边的listwidget和右边的stackedwidget,然后把 QHBoxLayout 的 layoutStretch 设置为 0,1,也就是满足listwidget的最小宽度前提下,让stackedwidget撑满整个layout容器

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

我是这么写的,但是并不起作用

self.hBoxLayout.setSpacing(0)
self.hBoxLayout.setContentsMargins(0, self.titleBar.height(), 0, 0)
self.hBoxLayout.addWidget(self.navigationInterface, 0, Qt.AlignLeft)
self.hBoxLayout.addWidget(self.stackWidget, 1, Qt.AlignLeft)

@Cheukfung
Copy link
Contributor Author

Cheukfung commented Mar 13, 2023

试试 self.hBoxLayout.setStretch(0,1)

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

解决了,改成下述代码就 ok 了,chatgpt 确实牛逼,偶尔的神

self.hBoxLayout.setSpacing(0)
self.hBoxLayout.setContentsMargins(0, self.titleBar.height(), 0, 0)
self.hBoxLayout.addWidget(self.navigationInterface)
self.hBoxLayout.addWidget(self.stackWidget)
self.hBoxLayout.setStretchFactor(self.stackWidget, 1)

@Cheukfung
Copy link
Contributor Author

就是把stretch设置为1就可以了

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 13, 2023

@Cheukfung @fsf678
我把最新代码提交上去了,运行 examples/navigation/demo.py 可以看到效果

@zhiyiYo zhiyiYo closed this as completed Mar 14, 2023
@Cheukfung
Copy link
Contributor Author

是不是没推到pypi呀

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 14, 2023

还没,你们可以先看下有没有问题吗,如果ok的话我就推上去

@Cheukfung
Copy link
Contributor Author

我运行了demo,没问题的

@Cheukfung
Copy link
Contributor Author

还有一个希望留个接口,实时切换dark mode

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 14, 2023

正在搞

@Ephemeralwanning
Copy link

正在搞

太好了大大,这下不用别人的主题了

@zhiyiYo
Copy link
Owner

zhiyiYo commented Mar 14, 2023

已将新版本的包发布到 pypi 了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants