Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User engrnaveed's Avatar
    Join Date
    Mar 2012
    Posts
    18
    Hi every one!
    Can any body please guide me how to distribute columns of QTableWidget evenly using code?
    I want the QTableWidget to be of maximum width of 360 pixels. but when the number of columns go beyond 3, a scroll bar appears.
    Now what I want is that the columns distribute themselves (by reducing their widths) to maintain the width of 360 & prevent the horizontal scroll bar to appear.
    Please someone guide me..

  2. #2
    Registered User kusumk's Avatar
    Join Date
    Sep 2011
    Posts
    449
    Did you already try below as per the documentation -

    The QTableWidget has the resizeColumnsToContents() method that resizes the columns. The below resizes the last column to fit to the right edge of the table.

    QHeaderView *HorizonHdr = ui.tableWidget->horizontalHeader();
    HorizonHdr->setStretchLastSection(true);


    One more method -

    QHeaderView *HorizonHdr = ui->tableWidget->horizontalHeader();

    HorizonHdr->setResizeMode(QHeaderView::Stretch);

  3. #3
    Registered User engrnaveed's Avatar
    Join Date
    Mar 2012
    Posts
    18
    Thanks kusumk...
    It solved the problem..

Similar Threads

  1. how to perform search in QTableWidget?
    By aurora26 in forum Qt
    Replies: 3
    Last Post: 2012-01-05, 11:57
  2. Moving rows in QTableWidget
    By nickich in forum Qt
    Replies: 0
    Last Post: 2011-02-23, 22:54
  3. Get rid of cell cursor in QTableWidget
    By syedzia5 in forum Qt
    Replies: 0
    Last Post: 2010-07-08, 13:03
  4. QTableWidget:how to control size?
    By davidmaxwaterman in forum Qt
    Replies: 7
    Last Post: 2010-03-24, 19:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved