久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='irJSr'></bdo><ul id='irJSr'></ul>

    <tfoot id='irJSr'></tfoot>
    <legend id='irJSr'><style id='irJSr'><dir id='irJSr'><q id='irJSr'></q></dir></style></legend>

  1. <i id='irJSr'><tr id='irJSr'><dt id='irJSr'><q id='irJSr'><span id='irJSr'><b id='irJSr'><form id='irJSr'><ins id='irJSr'></ins><ul id='irJSr'></ul><sub id='irJSr'></sub></form><legend id='irJSr'></legend><bdo id='irJSr'><pre id='irJSr'><center id='irJSr'></center></pre></bdo></b><th id='irJSr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='irJSr'><tfoot id='irJSr'></tfoot><dl id='irJSr'><fieldset id='irJSr'></fieldset></dl></div>

    <small id='irJSr'></small><noframes id='irJSr'>

    1. 創(chuàng)建要嵌入到 QMainWindow 中的小部件

      Create a widget to embed into QMainWindow(創(chuàng)建要嵌入到 QMainWindow 中的小部件)
      <tfoot id='mVtID'></tfoot><legend id='mVtID'><style id='mVtID'><dir id='mVtID'><q id='mVtID'></q></dir></style></legend>
    2. <small id='mVtID'></small><noframes id='mVtID'>

        • <i id='mVtID'><tr id='mVtID'><dt id='mVtID'><q id='mVtID'><span id='mVtID'><b id='mVtID'><form id='mVtID'><ins id='mVtID'></ins><ul id='mVtID'></ul><sub id='mVtID'></sub></form><legend id='mVtID'></legend><bdo id='mVtID'><pre id='mVtID'><center id='mVtID'></center></pre></bdo></b><th id='mVtID'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mVtID'><tfoot id='mVtID'></tfoot><dl id='mVtID'><fieldset id='mVtID'></fieldset></dl></div>
            <bdo id='mVtID'></bdo><ul id='mVtID'></ul>

                <tbody id='mVtID'></tbody>

                本文介紹了創(chuàng)建要嵌入到 QMainWindow 中的小部件的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我有這個(gè)我還不能解決的任務(wù).使用 PyQt 和 Qt Creator.

                我想將在 QT Creator 中創(chuàng)建的自定義小部件嵌入到另一個(gè) QMainWindow 中.

                1) 我做的步驟:

                在 QT creator 中創(chuàng)建一個(gè) Widget 文件:

                2) 將其保存為 *.ui 并應(yīng)用此行將其轉(zhuǎn)換為 *.py 文件:

                pyuic5 gen_settings.ui -o gen_settings.py

                3) 打開它,看到它以

                開頭

                從 PyQt5 導(dǎo)入 QtCore、QtGui、QtWidgets類 Ui_gen_settings(對(duì)象):def setupUi(self, gen_settings):gen_settings.setObjectName("gen_settings")

                4) 當(dāng)然會(huì)導(dǎo)致函數(shù)調(diào)用:

                TypeError:參數(shù)不匹配任何重載調(diào)用:addWidget(self, QWidget): 參數(shù) 1 具有意外類型函數(shù)"

                當(dāng)我在另一個(gè) QMainWindow 文件中調(diào)用它時(shí):

                類 Ui_MainWindow(object):def setupUi(self, MainWindow, My_Custom_widget):MainWindow.setObjectName("MainWindow")self.gridLayout.addWidget(My_Custom_widget, 1, 4, 1, 1)

                任何想法如何解決它?

                解決方案

                首先我推薦你閱讀

                圖片中,Widget容器是左上角的,現(xiàn)在我們將其替換為Gen_Settings,所以我們必須

                1. 將出現(xiàn)以下對(duì)話框并填寫如圖所示的字段(我假設(shè) gen_settings_ui.py 和 gen_settings.py 與當(dāng)前 .ui 位于同一文件夾中)

                1. 您按下添加按鈕,然后按下升級(jí)按鈕.

                <小時(shí)>

                然后你用 pyuic 將 .ui 轉(zhuǎn)換為 .py ,你會(huì)得到以下結(jié)果:

                從 PyQt5 導(dǎo)入 QtCore、QtGui、QtWidgets類 Ui_MainWindow(對(duì)象):def setupUi(self, MainWindow):MainWindow.setObjectName("MainWindow")# ...self.widget = Gen_Settings(self.centralwidget)self.widget.setObjectName("widget")self.gridLayout.addWidget(self.widget, 0, 0, 1, 1)# ...從 gen_settings 導(dǎo)入 Gen_Settings

                I have this task that I couldn't solve yet. Working with PyQt and Qt Creator.

                I want to embed a custom created widget created in QT Creator into another QMainWindow.

                1) Steps I do:

                Create a Widget file in QT creator:

                2) Save it as *.ui and apply this line to convert it to a *.py file:

                pyuic5 gen_settings.ui -o gen_settings.py
                

                3) Open it and see that it starts with

                from PyQt5 import QtCore, QtGui, QtWidgets
                
                class Ui_gen_settings(object):
                    def setupUi(self, gen_settings):
                        gen_settings.setObjectName("gen_settings")
                

                4) Which results in function call of course:

                TypeError: arguments did not match any overloaded call:
                  addWidget(self, QWidget): argument 1 has unexpected type 'function'
                

                when I call it in another QMainWindow file:

                class Ui_MainWindow(object):
                    def setupUi(self, MainWindow, My_Custom_widget):
                        MainWindow.setObjectName("MainWindow")
                        self.gridLayout.addWidget(My_Custom_widget, 1, 4, 1, 1)
                

                Any ideas how to solve it?

                解決方案

                First of all I recommend you read the PyQt docs referring to Qt Designer.

                Going to the problem, Qt Designer does not provide a widget but a class that serves as an interface to a widget, and that can be seen in his statement:

                class Ui_gen_settings(object):
                    # ...
                

                The class inherits from object and not from QWidget, QDialog, QMainWindow, etc.

                In the docs that indicate initially it is recommended to create a widget and use the interface provided by Qt Designer. For this it is correct to use pyuic but I will change the gen_settings.py to gen_settings_ui.py so that the change is understood.

                pyuic5 gen_settings.ui -o gen_settings_ui.py
                

                So now we create a file called gen_settings.py that contains the widget and use the interface.

                gen_settings.py

                from gen_settings_ui import Ui_gen_settings
                from PyQt5 import QtWidgets
                
                
                class Gen_Settings(QtWidgets.QWidget, Ui_gen_settings):
                    def __init__(self, parent=None):
                        super(Gen_Settings, self).__init__(parent)
                        self.setupUi(self)
                


                Then when you create the .ui corresponding to Ui_MainWindow you add a QWidget that is an empty container.

                In the image, the Widget container is the one in the upper left, and now we will replace it with Gen_Settings, so we must promote it using the following procedure:

                1. Right click on the widget container and select the Promote To ... option.

                1. The following Dialog will appear and fill in the fields as shown in the image (I'm assuming that gen_settings_ui.py and gen_settings.py are in the same folder as the current .ui)

                1. You press the Add button and then the Promote button.


                Then you convert the .ui to .py with pyuic and you will get the following:

                from PyQt5 import QtCore, QtGui, QtWidgets
                
                class Ui_MainWindow(object):
                    def setupUi(self, MainWindow):
                        MainWindow.setObjectName("MainWindow")
                        # ...
                        self.widget = Gen_Settings(self.centralwidget)
                        self.widget.setObjectName("widget")
                        self.gridLayout.addWidget(self.widget, 0, 0, 1, 1)
                        # ...
                
                from gen_settings import Gen_Settings
                

                這篇關(guān)于創(chuàng)建要嵌入到 QMainWindow 中的小部件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)

                    <tfoot id='8qW2y'></tfoot>

                  • <small id='8qW2y'></small><noframes id='8qW2y'>

                        <tbody id='8qW2y'></tbody>
                    1. <i id='8qW2y'><tr id='8qW2y'><dt id='8qW2y'><q id='8qW2y'><span id='8qW2y'><b id='8qW2y'><form id='8qW2y'><ins id='8qW2y'></ins><ul id='8qW2y'></ul><sub id='8qW2y'></sub></form><legend id='8qW2y'></legend><bdo id='8qW2y'><pre id='8qW2y'><center id='8qW2y'></center></pre></bdo></b><th id='8qW2y'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8qW2y'><tfoot id='8qW2y'></tfoot><dl id='8qW2y'><fieldset id='8qW2y'></fieldset></dl></div>
                        <legend id='8qW2y'><style id='8qW2y'><dir id='8qW2y'><q id='8qW2y'></q></dir></style></legend>
                          <bdo id='8qW2y'></bdo><ul id='8qW2y'></ul>
                          主站蜘蛛池模板: 亚洲高清在线 | 国产精品日本一区二区在线播放 | 亚洲国产成人精品久久久国产成人一区 | 放个毛片看看 | 在线视频a| 精品香蕉一区二区三区 | 中国免费黄色片 | 日本不卡一区二区三区 | 国产91在线播放 | 久久亚洲一区 | 日韩欧美在线一区 | 欧美中文字幕一区二区 | 精品一区二区在线观看 | 午夜电影福利 | 色婷婷亚洲一区二区三区 | japanhd成人| 亚洲综合大片69999 | 久久久久久久久久毛片 | 亚洲高清成人在线 | 国产我和子的乱视频网站 | 国产福利网站 | 国产97在线视频 | 密室大逃脱第六季大神版在线观看 | 天天爽天天干 | 欧美日韩高清一区二区三区 | 午夜电影网 | 91精品国产综合久久久久久蜜臀 | 亚洲精品福利视频 | 亚洲成人三区 | 午夜电影福利 | www.se91 | 国产精品毛片无码 | 91天堂网| 欧美日日 | 91麻豆精品一区二区三区 | 日韩中文字幕一区 | 少妇诱惑av | 黄色小视频大全 | 中文字幕视频在线观看 | 久久影音先锋 | 中文字幕亚洲欧美日韩在线不卡 |