Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: QTableWidget Not expanding to size of QDockWidget

  1. #21
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,687
    Thanks
    257
    Thanked 748 Times in 738 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTableWidget Not expanding to size of QDockWidget

    This is a really confused design. "PhysEqSolver" is, in effect, the model, since it appears to be the source of data that is displayed in the table. It is completely unnecessary to derive this from QTableView and in fact that might be part of the source of your GUI problems.

    The PhysEqSolverTable table widget that is created as part of the PhysEqSolver class should be the instance that is inserted into the dock widget. It should be created by the code that creates the dock widget (a QMainWindow-based class, likely). If for convenience, you want to store a copy of that pointer in the PhysEqSolver class, that's fine, but the Model / View architecture works the other way around - the model pointer is stored on the view, not vice-versa.

    Most of the code you have in the PhysEqSolver class for interacting with the table cells should be moved to the PhysEqSolverTable class. This is probably another source of GUI problems since it is likely you are handling signals for one GUI object (the table VIEW) using a different GUI object (the table WIDGET).

  2. #22
    Join Date
    Sep 2015
    Posts
    50
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTableWidget Not expanding to size of QDockWidget

    Quote Originally Posted by d_stranz View Post
    This is a really confused design. "PhysEqSolver" is, in effect, the model, since it appears to be the source of data that is displayed in the table. It is completely unnecessary to derive this from QTableView and in fact that might be part of the source of your GUI problems.

    The PhysEqSolverTable table widget that is created as part of the PhysEqSolver class should be the instance that is inserted into the dock widget. It should be created by the code that creates the dock widget (a QMainWindow-based class, likely). If for convenience, you want to store a copy of that pointer in the PhysEqSolver class, that's fine, but the Model / View architecture works the other way around - the model pointer is stored on the view, not vice-versa.

    Most of the code you have in the PhysEqSolver class for interacting with the table cells should be moved to the PhysEqSolverTable class. This is probably another source of GUI problems since it is likely you are handling signals for one GUI object (the table VIEW) using a different GUI object (the table WIDGET).
    Ahhhhhhh. Okay...

    This was the way that the sample I used was designed. Since I am learning and new to QT I have just run with it.

    I'll redesign some and see if that helps the UI issue...

  3. #23
    Join Date
    Sep 2015
    Posts
    50
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTableWidget Not expanding to size of QDockWidget

    Hey there Anda I finally had a chance to review this and yes after some investigation I realised that perhaps because I was developing the UI myself rather than use the QT Creator I wasn't doing it correctly. So I branched my code and rebuilt the UI using the QT Creator app, thereby doing it the right way, and many issues I was having are no longer there.

    In addition i came to realise that my understanding of the View/Model architecture was sorely lacking so I spent some time with that as well. Although much of my application remains the same, the UI base has been refactored greatly and the problems I was encountering in this thread are now gone. That was because I was confused by the documentation between QTableView and QTableWidget when it said that QTableWidget is a helper class...

    Anyway, this problem has now been averted.

Similar Threads

  1. Layout Expanding Font Size
    By Henry Blue Heeler in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2015, 06:55
  2. Replies: 2
    Last Post: 3rd January 2015, 05:48
  3. Dealing with Layout expanding size
    By edxxgardo in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2011, 10:20
  4. Replies: 1
    Last Post: 20th May 2011, 17:36
  5. Expanding QToolButton size
    By kodiak in forum Qt Programming
    Replies: 2
    Last Post: 4th June 2009, 07:17

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.