一切正常,唯一的问题是在两个字段QTextView中光标(垂直棒)的大小都小于透明文本的大小placeHolderText。
当您键入时,光标大小会标准化,但是если удалить все написанное,字体会变清晰становится маленьким(之后它不会恢复到正常的字体大小)。
谁会提示,它可以连接什么?
来自Qt 设计器的代码:
# -*- coding: utf-8 -*-
from PySide2 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("Encoder")
MainWindow.resize(800, 606)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.button_decrypt = QtWidgets.QPushButton(self.centralwidget)
self.button_decrypt.setGeometry(QtCore.QRect(330, 250, 111, 31))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(14)
self.button_decrypt.setFont(font)
self.button_decrypt.setCursor(QtCore.Qt.PointingHandCursor)
self.button_decrypt.setStyleSheet("QPushButton {\n"
" background-color: rgb(215, 215, 215);\n"
" border: 1px solid gray;\n"
"}\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #BEBEBE, stop: 1 #D7D7D7);\n"
"}")
self.button_decrypt.setObjectName("button_decrypt")
self.button_ecnrypt = QtWidgets.QPushButton(self.centralwidget)
self.button_ecnrypt.setGeometry(QtCore.QRect(210, 250, 111, 31))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(14)
self.button_ecnrypt.setFont(font)
self.button_ecnrypt.setCursor(QtCore.Qt.PointingHandCursor)
self.button_ecnrypt.setStyleSheet("QPushButton {\n"
" background-color: rgb(215, 215, 215);\n"
" border: 1px solid gray;\n"
"}\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #BEBEBE, stop: 1 #D7D7D7);\n"
"}")
self.button_ecnrypt.setObjectName("button_ecnrypt")
self.text_to = QtWidgets.QTextEdit(self.centralwidget)
self.text_to.setGeometry(QtCore.QRect(10, 10, 781, 231))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(16)
self.text_to.setFont(font)
self.text_to.setProperty("cursor", QtCore.Qt.IBeamCursor)
self.text_to.setFrameShape(QtWidgets.QFrame.NoFrame)
self.text_to.setObjectName("text_to")
self.text_from = QtWidgets.QTextEdit(self.centralwidget)
self.text_from.setGeometry(QtCore.QRect(10, 290, 781, 261))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(16)
self.text_from.setFont(font)
self.text_from.setProperty("cursor", QtCore.Qt.IBeamCursor)
self.text_from.setFrameShape(QtWidgets.QFrame.NoFrame)
self.text_from.setObjectName("text_from")
self.key_line = QtWidgets.QLineEdit(self.centralwidget)
self.key_line.setGeometry(QtCore.QRect(450, 250, 341, 31))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(16)
self.key_line.setFont(font)
self.key_line.setCursor(QtCore.Qt.IBeamCursor)
self.key_line.setObjectName("key_line")
self.choise_box = QtWidgets.QComboBox(self.centralwidget)
self.choise_box.setGeometry(QtCore.QRect(10, 250, 191, 31))
font = QtGui.QFont()
font.setFamily("Consolas")
font.setPointSize(14)
self.choise_box.setFont(font)
self.choise_box.setCursor(QtCore.Qt.PointingHandCursor)
self.choise_box.setObjectName("choise_box")
self.choise_box.addItem("")
self.choise_box.addItem("")
self.choise_box.addItem("")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtWidgets.QApplication.translate("MainWindow", "MainWindow", None, -1))
self.button_decrypt.setText(QtWidgets.QApplication.translate("MainWindow", "Decrypt", None, -1))
self.button_ecnrypt.setText(QtWidgets.QApplication.translate("MainWindow", "Encrypt", None, -1))
self.text_to.setHtml(QtWidgets.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML "
"4.0//EN\" "
"\"http://www.w3.org/TR/REC-html40/strict"
".dtd\">\n "
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Consolas\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; "
"-qt-block-indent:0; text-indent:0px; "
"font-family:\'MS Shell Dlg 2\'; "
"font-size:8.25pt;\"><br "
"/></p></body></html>", None, -1))
self.text_to.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "text", None, -1))
self.text_from.setHtml(QtWidgets.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
"HTML 4.0//EN\" "
"\"http://www.w3.org/TR/REC-html40"
"/strict.dtd\">\n "
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Consolas\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; "
"-qt-block-indent:0; text-indent:0px; "
"font-family:\'MS Shell Dlg 2\'; "
"font-size:8.25pt;\"><br "
"/></p></body></html>", None, -1))
self.text_from.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "text", None, -1))
self.key_line.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "key", None, -1))
self.choise_box.setItemText(0, QtWidgets.QApplication.translate("MainWindow", "Caesars code", None, -1))
self.choise_box.setItemText(1, QtWidgets.QApplication.translate("MainWindow", "Gronsfeld code", None, -1))
self.choise_box.setItemText(2, QtWidgets.QApplication.translate("MainWindow", "test", None, -1))
主.py:
from random import randint
import sys
class cryptoMain(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(cryptoMain, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
win = cryptoMain()
win.show()
sys.exit(app.exec_())
他没有说明纽扣的绑定,因为。问题仅在文本框中。
删除行:
我在一个地方删除,感觉不同。