Example #1
0
class DlgQRLogin(QDialog):
    """
    二维码登录对话框
    """
    def __init__(self, chat_):
        super().__init__()
        self.chat = chat_
        self.ui = Ui_ui_login()
        self.ui.setupUi(self)

        # 接收二维码
        self.chat.sign_qr.connect(self.show_qr)

    def show_qr(self, qrcode):
        img_qr = QImage.fromData(qrcode)
        pix_qr = QPixmap.fromImage(img_qr)
        self.ui.lbl_qr.setPixmap(pix_qr)
        self.ui.lbl_qr.setScaledContents(True)
Example #2
0
class DlgQRLogin(QDialog):
    def __init__(self, chat_):
        super().__init__()
        self.chat = chat_
        self.ui = Ui_ui_login()
        self.ui.setupUi(self)
        self.ui.lbl_qr.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.ui.closeButton.clicked.connect(QApplication.quit)

        # Get QR Code
        self.chat.sign_qr.connect(self.show_qr)

    def show_qr(self, qrcode):
        img_qr = QImage.fromData(qrcode)
        pix_qr = QPixmap.fromImage(img_qr)
        self.ui.lbl_qr.setPixmap(pix_qr)
        self.ui.lbl_qr.setScaledContents(True)
        self.ui.lbl_qr.setCursor(QCursor(Qt.ArrowCursor))

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.m_flag = True
            self.m_Position = event.globalPos() - self.pos()  # 获取鼠标相对窗口的位置
            event.accept()
            self.setCursor(QCursor(Qt.OpenHandCursor))  # 更改鼠标图标

    def mouseMoveEvent(self, QMouseEvent):
        if Qt.LeftButton and self.m_flag:
            self.move(QMouseEvent.globalPos() - self.m_Position)  # 更改窗口位置
            QMouseEvent.accept()

    def mouseReleaseEvent(self, QMouseEvent):
        self.m_flag = False
        self.setCursor(QCursor(Qt.ArrowCursor))

    def error(self):
        errBox = QMessageBox()
        errBox.setWindowFlags(Qt.FramelessWindowHint)
        errBox.setText("登录失败,可能该账号被禁止登录")
        errBoxRun = errBox.exec_()
        if errBoxRun:
            QApplication.quit()
Example #3
0
class DlgQRLogin(QDialog):
    """
    二维码登录对话框(弹出来)
    """
    def __init__(self, chat_):
        super().__init__()
        self.chat = chat_
        self.ui = Ui_ui_login()
        self.ui.setupUi(self)
        # 自己写的 # self.setGeometry(500, 400, 400, 300)    # 构造窗体 位置 大小
        # self.setWindowTitle('登录')   # 构造窗体标题

        # 接收二维码
        self.chat.sign_qr.connect(self.show_qr)

    def show_qr(self, qrcode):
        img_qr = QImage.fromData(qrcode)
        pix_qr = QPixmap.fromImage(img_qr)
        self.ui.lbl_qr.setPixmap(pix_qr)
        self.ui.lbl_qr.setScaledContents(True)
Example #4
0
class DlgQRLogin(QDialog):
    """
    二维码登录对话框
    """

    def __init__(self, chat_):
        super().__init__()
        # self.setGeometry(100, 100, 400, 300)  # 加密锤
        # self.setWindowTitle('登录')
        self.chat = chat_
        self.ui = Ui_ui_login()
        self.ui.setupUi(self)

        # 接收二维码
        self.chat.sign_qr.connect(self.show_qr)  # qr信号绑定在一个糟函数上

    def show_qr(self, qrcode):
        img_qr = QImage.fromData(qrcode)  # 转成图片
        pix_qr = QPixmap.fromImage(img_qr)  # 图片转换成像素
        self.ui.lbl_qr.setPixmap(pix_qr)  # 把像素加载到标签框
        self.ui.lbl_qr.setScaledContents(True)  # 设置二维码按窗体大小铺