1.UI

storyboard文件的认识

  • 用来描述软件界面
  • 默认情况下,程序一启动就会加载Main.storyboard
  • 加载storyboard时,会首先创建和显示箭头所指的控制器界面

IBAction和IBOutlet

  • IBAction:

    • 本质就是void
    • 能让方法具备连线的功能
  • IBOutlet

    • 能让属性具备连线的功能

storyboard连线容易出现的问题

  • 连接的方法代码被删掉,但是连线没有去掉

    • 可能会出现方法找不到错误
    • unrecognized selector sent to instance
  • 连接的属性代码被删掉,但是连线没有去掉

    • setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key

UIViewController(控制器)的认识

  • 一个控制器负责管理一个大界面
  • 控制器负责界面的创建、事件处理等

类扩展

  • 格式

    @interface 类名()
    /* 属性、方法的声明 /
    @end

  • 作用

    • 为某个类增加额外的属性和方法声明
    • 可以写在.h和.m文件中

项目属性

  • Product Name
    • 软件名称、产品名称、项目名称
  • Organization Name
    • 公司名称、组织名称
  • Organization Identifier
    • 公司的唯一标识
    • 一般是公司域名的反写,比如com.520it
  • Bundle Identifier
    • 软件的唯一标识
    • 一般是Organization Identifier + Product Name
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用QTimer对象代替QBasicTimer对象,修改程序class MyWindow(QWidget): def init(self): super().init() self.thread_list = [] self.color_photo_dir = os.path.join(os.getcwd(), "color_photos") self.depth_photo_dir = os.path.join(os.getcwd(), "depth_photos") self.image_thread = None self.saved_color_photos = 0 # 定义 saved_color_photos 属性 self.saved_depth_photos = 0 # 定义 saved_depth_photos 属性 self.init_ui() def init_ui(self): self.ui = uic.loadUi("C:/Users/wyt/Desktop/D405界面/intelrealsense1.ui") self.open_btn = self.ui.pushButton self.color_image_chose_btn = self.ui.pushButton_3 self.depth_image_chose_btn = self.ui.pushButton_4 self.open_btn.clicked.connect(self.open) self.color_image_chose_btn.clicked.connect(lambda: self.chose_dir(self.ui.lineEdit, "color")) self.depth_image_chose_btn.clicked.connect(lambda: self.chose_dir(self.ui.lineEdit_2, "depth")) def open(self): self.profile = self.pipeline.start(self.config) self.is_camera_opened = True self.label.setText('相机已打开') self.label.setStyleSheet('color:green') self.open_btn.setEnabled(False) self.close_btn.setEnabled(True) self.image_thread = ImageThread(self.pipeline, self.color_label, self.depth_label, self.interval, self.color_photo_dir, self.depth_photo_dir, self._dgl) self.image_thread.saved_color_photos_signal.connect(self.update_saved_color_photos_label) self.image_thread.saved_depth_photos_signal.connect(self.update_saved_depth_photos_label) self.image_thread.start() def chose_dir(self, line_edit, button_type): my_thread = MyThread(line_edit, button_type) my_thread.finished_signal.connect(self.update_line_edit) self.thread_list.append(my_thread) my_thread.start()
最新发布
05-26
以下是使用QTimer对象代替QBasicTimer对象的修改后的代码: ```python from PyQt5.QtCore import QTimer class MyWindow(QWidget): def __init__(self): super().__init__() self.thread_list = [] self.color_photo_dir = os.path.join(os.getcwd(), "color_photos") self.depth_photo_dir = os.path.join(os.getcwd(), "depth_photos") self.image_thread = None self.saved_color_photos = 0 self.saved_depth_photos = 0 self.init_ui() def init_ui(self): self.ui = uic.loadUi("C:/Users/wyt/Desktop/D405界面/intelrealsense1.ui") self.open_btn = self.ui.pushButton self.color_image_chose_btn = self.ui.pushButton_3 self.depth_image_chose_btn = self.ui.pushButton_4 self.open_btn.clicked.connect(self.open) self.color_image_chose_btn.clicked.connect(lambda: self.chose_dir(self.ui.lineEdit, "color")) self.depth_image_chose_btn.clicked.connect(lambda: self.chose_dir(self.ui.lineEdit_2, "depth")) def open(self): self.profile = self.pipeline.start(self.config) self.is_camera_opened = True self.label.setText('相机已打开') self.label.setStyleSheet('color:green') self.open_btn.setEnabled(False) self.close_btn.setEnabled(True) self.image_thread = ImageThread(self.pipeline, self.color_label, self.depth_label, self.interval, self.color_photo_dir, self.depth_photo_dir, self._dgl) self.image_thread.saved_color_photos_signal.connect(self.update_saved_color_photos_label) self.image_thread.saved_depth_photos_signal.connect(self.update_saved_depth_photos_label) self.image_thread.start() self.timer = QTimer(self) # 创建QTimer对象 self.timer.timeout.connect(self.update) # 连接timeout信号与槽函数 self.timer.start(100) # 启动定时器,间隔为100ms def update(self): # 检查所有的线程是否已完成,并从线程列表中移除已完成的线程 for thread in self.thread_list: if not thread.isRunning(): self.thread_list.remove(thread) def chose_dir(self, line_edit, button_type): my_thread = MyThread(line_edit, button_type) my_thread.finished_signal.connect(self.update_line_edit) self.thread_list.append(my_thread) my_thread.start() def update_saved_color_photos_label(self, count): self.saved_color_photos = count self.ui.label_5.setText(str(self.saved_color_photos)) def update_saved_depth_photos_label(self, count): self.saved_depth_photos = count self.ui.label_6.setText(str(self.saved_depth_photos)) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值