Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

PyQT5 sizing issue with QTableView and QGridLayout

$
0
0

I built a GUI program that has outputs on single line tables, and I recently updated it using QGridLayout to make it dynamically adjust to different system scalings.

The issue I'm having is the pandas table I load into the QTableView widget seems to be expanding the row to take up a ridiculously large amount of space in the window:

Demonstration of Scaling issue

I have tried setting the minimum row height using setRowHeight( ... ) to a smaller value and setting setRowStretch to 0, but it doesn't do anything. Resizing the table object also has no effect.

Here is the code:

            # Table Results            self.Table = QTableView()            __dfwa = pd.DataFrame()            __dfwa['# of Neighbours']                      = np.array([None])            __dfwa['Weighted Average Percent Removal [%]'] = np.array([None])            __modelwa                                      = pandasModel(__dfwa)            self.Table.setModel(__modelwa)            self.Table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)            self.Table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)            self.vbox.addWidget(self.Table, 49,15,1,22)

Where self.vbox is called using:

self.vbox = QGridLayout()

I also know it isn't another object on this row causing issues because if the table is deleted, then the whole GUI rescales to its proper proportions.

I've tried:

self.Table.resize(375, 20)

and

self.vbox.setRowMinimumHeight(49,20)self.vbox.setRowStretch(49,0)

I've changed up the values in the functions and it has no effect. If anyone has run into this issue before and found a solution it would be very helpful as I've been stuck on this for a while now. Thanks in advance!


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>