Results 1 to 8 of 8

Thread: QTableView not working as expected.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: QTableView not working as expected.

    you creates QStandardItemModel model(5, 2); in a stack (an object will be destroyed when out of scope). you should create in the heap, i.e. QStandardItemModel *model = new QStandardItemModel(5, 2);.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  2. #2
    Join Date
    Jul 2009
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView not working as expected.

    ahh ty, cause the book used it in the main function. Thanks for your expertise

  3. #3
    Join Date
    Jul 2009
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView not working as expected.

    After successfully implementing the QTableView, how do i make it stretch fully? As there are gaps on the right and bottom.

  4. #4
    Join Date
    Jul 2009
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView not working as expected.

    im not sure if im allowed to do this, bumps.

  5. #5
    Join Date
    Jul 2009
    Posts
    139
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 59 Times in 52 Posts

    Default Re: QTableView not working as expected.

    Try:
    Qt Code:
    1. table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jul 2009
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView not working as expected.

    Thanks for the help but it doesnt seem to be working.

    edit: it seems that it isnt the QTableView that is not expanding, rather it is the model that it is displaying that doesnt expand.
    Last edited by junxuan; 29th July 2009 at 13:48.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QTableView not working as expected.

    You don't need line 23 in your original post.

    Maybe:
    Qt Code:
    1. table->horizontalHeader()->setStretchLastSection(true);
    2. OR
    3. table->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 
    are more to your liking?

Similar Threads

  1. Replies: 2
    Last Post: 7th June 2009, 10:47
  2. Replies: 3
    Last Post: 26th April 2009, 17:54
  3. QTableView doubleclicked event not working
    By sgmurphy19 in forum Qt Programming
    Replies: 6
    Last Post: 15th March 2009, 10:00
  4. QTableView ::setColumnWidth not working?
    By killerwookie99 in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2008, 17:14
  5. Need help integrating sigc++ with a KDE3/Qt3 app
    By Valheru in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2007, 15:39

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
  •  
Qt is a trademark of The Qt Company.