Python Forum
[PyQt] Qtableview adapte size to
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Qtableview adapte size to
#1
Hello,

Is it possible to adapte the size of a Qtableview to the main window ? when I pull the window on the right side, I would like the Qtableview to adapt and expand horizontaly. But I don't want it to fill ALL the main window.

I have this :
[Image: 1584902327-capture1.png]
When I pull the window on the right, it should horizontaly adjusts:
[Image: 1584902332-capture2.png]
But at the moment it does nothing:
[Image: 1584902336-capture3.png]
So I tried many codes with QHboxLayout and other, but nothing works, the last I tried was this for instance:

      def initUI(self):
        self.statusBar()

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('File')
    
        self.centralwidget = QWidget(self)
        self.horizontalLayoutWidget = QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setGeometry(30, 10, 721, 171)
        self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.widget = QWidget(self.horizontalLayoutWidget)
        self.table_view = QTableView(self.widget)
        
        self.model = pandasModel(df)

        self.table_view.setModel(self.model)
        self.table_view.show()
        self.table_view.resizeColumnsToContents()
        
        self.setCentralWidget(self.centralwidget)
        self.resize(800, 600)  
        self.setWindowTitle('test')
        
    
        self.show()
But the result is even worse.

[Image: 1584902340-capture4.png]

Thank you in advance for you help.
Reply


Messages In This Thread
Qtableview adapte size to - by WBPYTHON - Mar-22-2020, 06:51 PM
RE: Qtableview adapte size to - by deanhystad - Mar-22-2020, 08:27 PM
RE: Qtableview adapte size to - by WBPYTHON - Mar-22-2020, 10:03 PM
RE: Qtableview adapte size to - by deanhystad - Mar-23-2020, 01:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] PyQt5 QTableView SQLite : edit cell HeinKurz 2 2,411 Mar-27-2023, 10:41 AM
Last Post: HeinKurz
  [PyQt] QStyledItemDelegate and QTableView malonn 1 1,651 Feb-07-2023, 07:15 PM
Last Post: malonn
  [PyQt] QTableView set header labels HeinKurz 2 6,823 Jan-23-2023, 08:46 AM
Last Post: HeinKurz
  [PyQt] Determine whether text in QTableView cell is fully visible or not random_nick 0 991 Oct-27-2022, 09:29 PM
Last Post: random_nick
  [PyQt] QTableView: scroll to top cell of the screen random_nick 2 2,857 Oct-08-2022, 12:29 AM
Last Post: random_nick
  [PyQt] [Solved]Add a Blank Row To QTableView Extra 3 5,568 Oct-02-2022, 04:53 PM
Last Post: Extra
  How to update the list of a combo box in a QTableView panoss 10 6,265 Feb-05-2022, 03:24 PM
Last Post: panoss
  [PyQt] How to Copy-Paste a table from Office apps to QTableView? Vittorio 5 7,266 Aug-05-2021, 11:14 AM
Last Post: Axel_Erfurt
  [Tkinter] Trying to change font size w/o changing button size python63 3 9,880 Aug-05-2020, 01:04 AM
Last Post: Larz60+
  [PyGUI] Showing text in QTableView sequence 0 3,081 Jan-20-2019, 05:00 PM
Last Post: sequence

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020