python - How to put a widget in a tab in PyQt5
问题描述
I'm currently working on a security camera project. It has mainly two functions:
- Catches the videoframes with faces
- Shows the captured frames
I succesfully wrote the code for both classes but a problem occurs when I try to put 2nd function
class Iwindow(QMainWindow, gui):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.setupUi(self)
self.cntr, self.numImages = -1, -1 # self.cntr have the info of which image is selected/displayed
self.image_viewer = ImageViewer(self.label)
self.showMaximized()
self.selectFolder.clicked.connect(self.selectDir)
self.nextImage.clicked.connect(self.nextImg)
self.prevImage.clicked.connect(self.prevImg)
self.listView.clicked.connect(self.item_click)
This is from the code for image displaying. When I try to put image viewer to a tab widget in another program it doesn't go under the tab when I try to do it.
#Create second tab
self.tab2.layout = QVBoxLayout(self)
self.imgViewWidget = Iwindow()
self.tab2.layout.addWidget(self.imgViewWidget)
self.tab2.layout = QVBoxLayout(self)
this is when I try to call widget. Could anyone help me?
this is the final product of my code
解决方案
推荐阅读
- c - 返回主菜单时出现问题 - C 编程
- node.js - 如何使用 Google Docs API 在特定位置插入图片
- r - 如何在ggplot中编辑当前的图例标签
- javascript - 如何在javascript中使用preventDefault删除默认操作?
- typo3 - 找不到 Typo3 V9 后端模块视图
- git - 不同的 git config 用户和 ssh 密钥,如何使 git pull 工作?
- swift - `tearDown` 调用是必要的吗?
- javascript - 如何在 React.js 中调整 Chart.JS 元素的大小?
- python - 所有主机的 Ansible 附加字典结果
- java - Bazel 等效于 Buck 的类路径