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

<tfoot id='ocPuO'></tfoot>

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

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

        為什么 QTableView 有空白邊距,我該如何刪除它們

        Why does QTableView have blank margins and how can I remove them?(為什么 QTableView 有空白邊距,我該如何刪除它們?)
          <i id='mAopw'><tr id='mAopw'><dt id='mAopw'><q id='mAopw'><span id='mAopw'><b id='mAopw'><form id='mAopw'><ins id='mAopw'></ins><ul id='mAopw'></ul><sub id='mAopw'></sub></form><legend id='mAopw'></legend><bdo id='mAopw'><pre id='mAopw'><center id='mAopw'></center></pre></bdo></b><th id='mAopw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mAopw'><tfoot id='mAopw'></tfoot><dl id='mAopw'><fieldset id='mAopw'></fieldset></dl></div>
        1. <small id='mAopw'></small><noframes id='mAopw'>

        2. <tfoot id='mAopw'></tfoot>

            <tbody id='mAopw'></tbody>

                  <bdo id='mAopw'></bdo><ul id='mAopw'></ul>
                • <legend id='mAopw'><style id='mAopw'><dir id='mAopw'><q id='mAopw'></q></dir></style></legend>

                  本文介紹了為什么 QTableView 有空白邊距,我該如何刪除它們?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  以下 PyQt 程序生成一個包含 QTableView 的窗口,其底部和右側(但不是頂部和左側)有一個邊距空間 - 即使主窗口被告知要調整其自身內容大小:

                  The following PyQt program produces a window containing a QTableView with a margin space to its bottom and right (but not top and left) - even though the main-window is told to adjust itself to its contents size:

                  期待看到:

                  如果我從原始位置增加窗口的大小,我會看到:

                  If I increase the size of the window from the original position, I see:

                  該區域的目的是什么?可以消除嗎?如果有,怎么做?

                  What is the purpose of that region? Can it be eliminated? If so, how?

                  import sys
                  
                  from PyQt5 import QtCore, QtWidgets
                  from PyQt5.QtCore import Qt
                  from PyQt5.QtWidgets import QVBoxLayout, QWidget, QApplication, QMainWindow, QTableView
                  
                  
                  class TableModel(QtCore.QAbstractTableModel):
                      def __init__(self):
                          super().__init__()
                  
                      def data(self, index, role=None):
                          if role == Qt.DisplayRole:
                              return 42
                  
                      def rowCount(self, index):
                          return 3
                  
                      def columnCount(self, index):
                          return 4
                  
                  
                  class MainWindow(QMainWindow):
                      def __init__(self):
                          super().__init__()
                  
                          self.table = QTableView()
                  
                          self.model = TableModel()
                          self.table.setModel(self.model)
                          self.table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
                  
                          self.setCentralWidget(self.table)
                  
                  
                  app = QApplication(sys.argv)
                  w = MainWindow()
                  w.show()
                  app.exec_()
                  

                  推薦答案

                  如果您不指定應該如何調整表格元素的大小,則空白區域是正常的和預期的.有許多不同的配置可以適應不同的用例,因此您可能需要進行一些試驗才能獲得所需的確切行為.

                  The blank areas are normal and expected if you don't specify how the elements of the table should be resized. There are many different configurations to suit different use-cases, so you may need to experiment a little to get the exact behaviour you want.

                  沿右側和底部邊緣的初始邊距用于允許滾動條.如果你不想要滾動條,你可以像這樣關閉它們:

                  The initial margins along the right and bottom edges are there to allow for scrollbars. If you don't want scrollbars, you can switch them off like this:

                      self.table.setHorizontalScrollBarPolicy(
                          QtCore.Qt.ScrollBarAlwaysOff)
                      self.table.setVerticalScrollBarPolicy(
                          QtCore.Qt.ScrollBarAlwaysOff)
                  

                  但是,當窗口調整大小時,空白區域仍然存在 - 但您可以通過設置 section resize模式,像這樣:

                  However, the blank areas will still be there when the window is resized - but you can deal with that by setting the section resize mode, like this:

                      self.table.horizontalHeader().setSectionResizeMode(
                          QtWidgets.QHeaderView.Stretch)
                  
                      self.table.verticalHeader().setSectionResizeMode(
                          QtWidgets.QHeaderView.Stretch)
                  

                  這可能會導致窗口的初始大小出現意外,因此建議設置適當的默認值:

                  This might result in an unexpected initial size for the window, so it may be advisable to set an appropriate default:

                      self.resize(400, 200)
                  

                  有關詳細信息,請參閱 QTableView 和 QHeaderView.

                  For further details, see the documentation for QTableView and QHeaderView.

                  這篇關于為什么 QTableView 有空白邊距,我該如何刪除它們?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='EBaxN'></small><noframes id='EBaxN'>

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

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

                          • <legend id='EBaxN'><style id='EBaxN'><dir id='EBaxN'><q id='EBaxN'></q></dir></style></legend>
                              <tbody id='EBaxN'></tbody>
                          • 主站蜘蛛池模板: 久久国产精品亚洲 | 精品久久久久香蕉网 | 欧美一区2区三区3区公司 | 久久视频精品在线 | 古装人性做爰av网站 | 久久亚洲精品国产精品紫薇 | 日韩精品无码一区二区三区 | 久久久久久国产精品 | 亚洲午夜视频 | 亚洲一区二区三区四区av | 欧美在线播放一区 | 精品久久久久久国产 | 91精品久久久久久久久久入口 | 99久久精品免费看国产小宝寻花 | 资源首页二三区 | 亚洲精品大片 | 午夜欧美 | 成人久久| 91中文字幕在线观看 | 中文字幕av第一页 | 久久久一区二区三区四区 | 欧美三级三级三级爽爽爽 | 欧美片网站免费 | 激情欧美一区二区三区中文字幕 | 99久久精品免费看国产免费软件 | 亚洲精品9999 | 国产成人免费视频 | 日韩不卡一区二区 | 成人精品久久 | 日韩成人在线观看 | 日韩毛片 | 99精品视频一区二区三区 | 在线观看中文字幕 | 国产yw851.c免费观看网站 | 久久久久无码国产精品一区 | 日韩高清一区 | 久久久久久成人 | 天天天操| 欧美亚洲视频在线观看 | 欧美精选一区二区 | 美国黄色毛片 |