确定Equals()是否为覆盖?(Determine if Equals() is an override?)
我有一个Type(type)的实例。 如何确定它是否覆盖Equals()?
I have an instance of Type (type). How can I determine if it overrides Equals()?
原文:https://stackoverflow.com/questions/3629605
满意答案
您的代码的主要问题是您为
StartQT4
子类使用了错误的基类。 它应该与Qt Designer中的顶级类匹配,后者是QDialog
。您还可以通过将ui直接添加到子类,以及使用新式信号和插槽语法来简化代码。
有了这些更改,您的代码将如下所示:
import sys from PyQt4 import QtCore, QtGui from simpleTextEditor_gui import Ui_simpleTextEditor class StartQT4(QtGui.QDialog, Ui_simpleTextEditor): def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # tutaj dajemy wlasne polaczenia slotow self.buttonOpen.clicked.connect(self.file_dialog) def file_dialog(self): fd = QtGui.QFileDialog(self) self.filename = fd.getOpenFileName() from os.path import isfile if isfile(self.filename): text = open(self.filename).read() self.editorWindow.setText(text) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = StartQT4() myapp.show() sys.exit(app.exec_())
The main problem with your code is that you are using the wrong base-class for your
StartQT4
subclass. It should match the top-level class from Qt Designer, which is aQDialog
.You can also simplify your code a little, by adding the ui directly to your sub-class, and by using new-style signal and slot syntax.
With these changes in place, your code would look like this:
import sys from PyQt4 import QtCore, QtGui from simpleTextEditor_gui import Ui_simpleTextEditor class StartQT4(QtGui.QDialog, Ui_simpleTextEditor): def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # tutaj dajemy wlasne polaczenia slotow self.buttonOpen.clicked.connect(self.file_dialog) def file_dialog(self): fd = QtGui.QFileDialog(self) self.filename = fd.getOpenFileName() from os.path import isfile if isfile(self.filename): text = open(self.filename).read() self.editorWindow.setText(text) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = StartQT4() myapp.show() sys.exit(app.exec_())
相关问答
更多Qt - QDialog小时候没有标题栏(Qt - QDialog as a child does not have title bar)
使用qt designer指定的QDialog的valgrind问题(valgrind issue with QDialog specified with qt designer)
Qt QDialog渲染堆叠(Qt QDialog rendering stacked)
带有确定和取消按钮的QDialog(QDialog with ok and cancel buttons)
在QT Designer中使用QDialog(Using QDialog in QT Designer)
如何使用Qt C ++在QDialog Window和QMainWindow之间进行通信(How to communicate between QDialog Window and QMainWindow with Qt C++)
QDialog:如何使用问号(?)按钮?(QDialog: how to use question mark (?) button?)
QDialog缺少边框(QDialog missing border)
qt c ++ QDialog打开新文件(qt c++ QDialog open new file)
使用信号和插槽在Qt中与MainWindow通信QDialog(Using Signals and Slots to Comunicate a QDialog with MainWindow in Qt)
相关文章
更多Java 重写(Override)与重载(Overload)
Guava学习笔记:复写的Object常用方法
这个测试,为什么总是false
solr dataimport 数据导入源码分析(七)
瞬间覆盖百万微信用户的新玩法 逼格高到没朋友
2009无线通信五大趋势 3G范围将覆盖全球
solr dataimport 数据导入源码分析(五)
spring的jdbctemplet的queryforObject()有异常,不知道原因
XStream的日期转换XStreamDateConverter
教你用大功率路由器实现覆盖3平方公里wix公众账号吸粉神器
最新问答
更多您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
在计算机拍照在哪里进入
使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
单页应用程序:页面重新加载(Single Page Application: page reload)
在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!