蟒蛇&qtDesigner uic 弹窗 lineEdit access [英] Python & qtDesigner uic pop-up window lineEdit access

查看:63
本文介绍了蟒蛇&qtDesigner uic 弹窗 lineEdit access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手.我想单击一个按钮来打开一个新窗口并从主窗口 lineEdit 中获取文本并复制到新的弹出窗口 lineEdit.

I'm newbie. I want to click a pushButton to open a new window and take text from main window lineEdit and copy to new pop-up window lineEdit.

到目前为止,我创建了一个新窗口,但无法访问 lineEdit.没有错误,应用没有响应.

So far I an create new window but can't access lineEdit. No errors, app is not responding.

这就是我所拥有的:

from PyQt5.QtWidgets import QApplication
from PyQt5 import uic

app = QApplication([]) #Main Window
ui = uic.loadUi(r"D:\UI_test\gui\main_gui_TT.ui")

appedit = QApplication([]) #Pop-up
uiedit = uic.loadUi(r"D:\UI_test\gui\input_TT.ui")

def edit1():
    uiedit.show()
    appedit.exec_()
    uiedit.lineEdit_CC.setText('text') <-this line is a problem


ui.pushButton_1edit.pressed.connect(edit1)
ui.show()
app.exec_()

请帮忙看看这里出了什么问题?

Please help what is wrong here?

推荐答案

即使你有很多窗口,你也应该只有一个 QApplication,考虑到上面的解决方案是:

You should only have a single QApplication even if you have many windows, considering the above the solution is:

from PyQt5.QtWidgets import QApplication
from PyQt5 import uic

app = QApplication([])  # Main Window
ui = uic.loadUi(r"D:\UI_test\gui\main_gui_TT.ui")

uiedit = uic.loadUi(r"D:\UI_test\gui\input_TT.ui")


def edit1():
    uiedit.show()
    uiedit.lineEdit_CC.setText("text")


ui.pushButton_1edit.pressed.connect(edit1)
ui.show()
app.exec_()

这篇关于蟒蛇&amp;qtDesigner uic 弹窗 lineEdit access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆