Results 1 to 10 of 10

Thread: Qtableview margin/padding

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2021
    Posts
    7
    Thanks
    2
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default Qtableview margin/padding

    Hi Team

    I have a small problem with tableview.
    The problem I have is that the QT designer view and the actual application view differ (as shown in the in the pic below).
    The table is somehow split in two columns, but when populating all data appears on the left side, including scroll bars.
    After import of my data, these views stay the same. My data appears in the left field (with scroll adjuster) whilst the right field stays blank.

    Attachment 13598
    Does anybody know what setting may need to change in QTdesigner (or in my code) to resolve this?

    Qt Code:
    1. from PyQt5 import QtCore, QtWidgets, uic
    2. from PyQt5.QtCore import Qt
    3. from PyQt5.QtGui import *
    4. from PyQt5.QtWidgets import (qApp, QComboBox, QMainWindow, QApplication, QMessageBox, QFileDialog)
    5.  
    6. #define class
    7. class Bathyui(QtWidgets.QDialog):
    8. def __init__(self, parent=None):
    9. super(Bathyui, self).__init__(parent)
    10. uic.loadUi('Open_File_UWN_Model.ui', self)
    11.  
    12. #connect to widget
    13. self.table = QtWidgets.QTableView(self.tableView)
    14.  
    15. #populate with dataframe
    16. self.table.setModel(file_reader)
    To copy to clipboard, switch view to plain text mode 

    Below the .ui code
    Attachment 13599

    Im a littlebit lost how to solve this. I pretty much hit every setting in the QT Designer formatting menu.
    Im using anaconda python with qt designer 5.11.1 included

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qtableview margin/padding

    For one thing, why are you not using layouts for such a complex form? It looks like you have put every widget in place with absolute size and positioning. This will almost certainly result in headaches if you resize the window or deploy it on a PC with different default magnification. Other than that bad problem, I don't see anything wrong with your UI file.

    I am not a Python expert, but isn't line 13 creating a second QTableView using the current self.tableView as its parent? This is probably why you are seeing two tables. The left-hand table is this new one, which is getting filled from your model, while the original table created from the UI file is underneath it and in the size you specified in the UI file.

    Get rid of line 13 and in line 16 use "self.tableView" to set the model.
    Last edited by d_stranz; 24th February 2021 at 18:48.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    Zoner (25th February 2021)

  4. #3
    Join Date
    Feb 2021
    Posts
    7
    Thanks
    2
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default Re: Qtableview margin/padding

    That was indeed the solution, and it looks like I need to go down the same road for some pyvistaqt graphs.
    I reckon Im still struggling with the widgets.

    Thanks for the tip with the layout form, I wondered why I couldnt read it right on my laptop, another one to add to my reading list.

    thanks d_stranz
    really appreciated!

Similar Threads

  1. Qtableview margin/padding
    By Zoner in forum Newbie
    Replies: 1
    Last Post: 24th February 2021, 17:08
  2. QListWidget margin/padding space
    By Hennessy in forum Newbie
    Replies: 0
    Last Post: 28th March 2014, 15:01
  3. QTabWidget icon padding/margin?
    By Nyte in forum Newbie
    Replies: 0
    Last Post: 2nd April 2013, 11:31
  4. Replies: 3
    Last Post: 25th June 2010, 05:21
  5. QPainter.drawText and margin/padding
    By invictus in forum Newbie
    Replies: 1
    Last Post: 24th July 2009, 12:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.