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

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

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

      1. <tfoot id='Qq1q9'></tfoot>

        如何在 PyQt4 中相對于標簽大小的變化保持按鈕不

        How to keep Push Buttons constant in relative to change of Label Size in PyQt4(如何在 PyQt4 中相對于標簽大小的變化保持按鈕不變)

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

        1. <tfoot id='qag99'></tfoot>
            <bdo id='qag99'></bdo><ul id='qag99'></ul>
            • <legend id='qag99'><style id='qag99'><dir id='qag99'><q id='qag99'></q></dir></style></legend>

                    <tbody id='qag99'></tbody>
                  <i id='qag99'><tr id='qag99'><dt id='qag99'><q id='qag99'><span id='qag99'><b id='qag99'><form id='qag99'><ins id='qag99'></ins><ul id='qag99'></ul><sub id='qag99'></sub></form><legend id='qag99'></legend><bdo id='qag99'><pre id='qag99'><center id='qag99'></center></pre></bdo></b><th id='qag99'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qag99'><tfoot id='qag99'></tfoot><dl id='qag99'><fieldset id='qag99'></fieldset></dl></div>
                  本文介紹了如何在 PyQt4 中相對于標簽大小的變化保持按鈕不變的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個圖像作為我在 PyQt4 程序中的標簽.該程序還包含一些按鈕.現在,當我最大化我的窗口時,雖然標簽得到擴展,但按鈕保留了它們的位置.我希望按鈕應該保持它們相對于標簽的相對位置,即使在最大化時也是如此.

                  I have an image as my label in a PyQt4 Program. This program also contains some push buttons. Now, when I maximize my window, though the label gets expanded but the push button retain their place. I want that the push buttons should maintain their relative position with respect to the label, even when maximized.

                  我的代碼如下:

                  class Ui_MainWindow(object):
                     def setupUi(self, MainWindow):
                  
                         self.centralwidget = QtGui.QWidget(MainWindow)
                         MainWindow.setCentralWidget(self.centralwidget)
                         lay = QtGui.QVBoxLayout(self.centralwidget)
                         self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
                         self.label = QtGui.QLabel(self.centralwidget)
                         self.label.setText(_fromUtf8(""))
                         self.label.setPixmap(QtGui.QPixmap(_fromUtf8("Capture.PNG")))
                         self.label.setObjectName(_fromUtf8("label"))
                         self.label.setScaledContents(True)
                         lay.addWidget(self.label)
                         self.Langdon = QtGui.QPushButton(self.centralwidget)
                         self.Langdon.setGeometry(QtCore.QRect(290, 90, 75, 23))
                         self.Langdon.setObjectName(_fromUtf8("Langdon"))     
                         self.ChainLakes = QtGui.QPushButton(self.centralwidget)
                         self.ChainLakes.setGeometry(QtCore.QRect(50, 290, 85, 23))
                         self.ChainLakes.setObjectName(_fromUtf8("ChainLakes"))
                  
                     if __name__ == "__main__":
                        import sys
                        app = QtGui.QApplication(sys.argv)
                        MainWindow = QtGui.QMainWindow()
                        ui = Ui_MainWindow()
                        ui.setupUi(MainWindow)
                        MainWindow.show()
                        sys.exit(app.exec_())
                  

                  我應該如何修改我的代碼??

                  How shall I modify my code??

                  推薦答案

                  您對按鈕使用絕對定位,而對標簽使用相對定位(因為它在布局中).由于按鈕是絕對定位的,因此只要容器大小(您的主窗口或中央小部件)發生變化,您就有責任在自己周圍移動它們.OTOH,如果您使用布局定位它們,則布局會根據需要移動它們(與標簽一樣).

                  You're using absolute positioning for the buttons, but relative for the label (because it is in the layout). Since the buttons are positioned absolutely, you're responsible for moving them around yourself whenever the container size (your main window or central widget) changes. OTOH if you position them using a layout, the layout then moves them around as needed (as with the label).

                  我強烈建議您找到一個適合您需求的基于布局的解決方案(它們非常靈活,但有時可能需要一些小技巧).除此之外,您需要子類化容器(您的 centralWidget QWidget)并重新實現 QWidget::resizeEvent() 處理程序.在該處理程序中,您將根據容器的當前大小和標簽的當前大小/位置將絕對定位的元素(按鈕)移動到新位置.

                  I highly recommend you find a layout-based solution which would suit your needs (they're very flexible but can sometimes take a bit of fiddling). Barring that, you'll need to subclass the container (your centralWidget QWidget) and re-implement the QWidget::resizeEvent() handler. Inside that handler you would move the absolutely positioned elements (the buttons) to a new position based on current size of the container and current size/position of the label.

                  我對 PyQt 不夠方便,無法給出具體示例(抱歉),但我確實為可能有用的 C++ 問題提供了類似的答案:QPushButton 在另一個小部件頂部對齊

                  I'm not handy enough with PyQt to give a concrete example (sorry), but I did provide a similar answer to a C++ question which may be useful: QPushButton alignment on top another widget

                  這篇關于如何在 PyQt4 中相對于標簽大小的變化保持按鈕不變的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 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 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

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

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

                          1. 主站蜘蛛池模板: 日本少妇一区二区 | 中文字幕免费看 | 亚洲视频一区二区三区四区 | 五月婷婷| 日韩精品一区二区三区四区 | 国产成人三级 | 狠狠干夜夜操 | 免费a视频 | 91精品国产99久久久久久红楼 | 黄色片网站在线观看 | 亚洲国产成人精品女人久久久 | 伊人干综合 | 国产午夜精品一区二区三区视频 | 青青草国产精品 | 久久精彩| 国产精品久久久久久久久久久久午夜片 | 国产午夜一区二区 | 亚洲欧美日本在线 | 天天射天天干天天操 | 玖玖视频在线 | 欧美日韩小视频 | 精品欧美一区二区精品久久 | 久久精品国产77777蜜臀 | 性做久久 | 日韩一区二区三区在线 | 在线a视频 | 国产黄色免费看 | 日韩少妇av | 欧美一级免费 | 黄色一级在线观看 | 欧美日韩在线播放 | 午夜无遮挡 | 四虎影视大全 | 亚洲欧美日韩国产精品 | 精品黄色片 | 日韩免费在线观看 | 国产精品久久久久久久成人午夜 | 18成人免费观看网站 | 一级做a爱片性色毛片 | 国产又粗又猛又黄又爽的视频 | 成人婷婷 |