久久久久久久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>
                          • 主站蜘蛛池模板: 久久手机视频 | 九九久久99 | 999久久久| 日本成人在线观看网站 | 欧美三级三级三级爽爽爽 | 欧美a区| 黑人巨大精品欧美一区二区一视频 | 国产一区二区久久 | 欧美日韩久 | 久草免费在线视频 | 国产一区二区高清在线 | 中文字幕亚洲欧美 | 欧美乱码精品一区二区三区 | 国产成人精品久久二区二区91 | 青青草社区 | 五月婷婷导航 | 中文字幕在线网 | 国产精品一区二区福利视频 | 欧美视频一级 | 精品国产欧美一区二区 | 欧美日韩专区 | 欧美日韩综合视频 | 久久精品视频网站 | 日韩精品国产精品 | 精品久久99 | 特一级毛片 | 97成人精品 | 国产精品久久久久久久久久东京 | 亚洲视频在线看 | 日本精品一区二区 | 一区二区三区在线免费观看 | 久久久久久久久国产成人免费 | 超碰在线影院 | 亚洲第一天堂 | 自拍偷拍中文字幕 | 国产精品成人一区二区三区 | 久久香蕉精品视频 | 亚洲在线 | 日韩视频免费 | 免费麻豆视频 | 极品久久 |