Results 1 to 7 of 7

Thread: QTableWidget view problem

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QTableWidget view problem

    Hi,

    I checked the documentation but I couldn't find if there is a way to remove borders between the columns of the table. Is there a way to perform this task?

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

    Default Re: QTableWidget view problem

    they depend from style. so, you can try to write your own style or use your own stylesheet insted.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QTableWidget view problem

    Hi again,

    I see what you are saying but I couldn't give a style for the header rows or columns. They only return integers when I said ...columnAt(int x) unlike table cells. Thus, I couldn't play with their styles. When I tried to change the style from the tablewidget itself ( i.e.: myTableWidget.setStyleSheet("border-style:none")); ) , it only removes the border of the cells but not the header columns and rows.

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

    Default Re: QTableWidget view problem

    try this (from Qt Assistant)
    QHeaderView::section {
    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
    stop:0 #616161, stop: 0.5 #505050,
    stop: 0.6 #434343, stop:1 #656565);
    color: white;
    padding-left: 4px;
    border: 1px solid #6c6c6c;
    }
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QTableWidget view problem

    Ok it worked!

    By the way, is there a way to exclude horizontal header of the table widget from the table widget's frame?

    I tried horizontalHeader.setFrameStyle(QFrame::NoFrame), not interestingly it didn't work

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QTableWidget view problem

    I have one more question that I just encountered that is;

    I want to setTextAlignment for the items in the table such as the following:

    Qt Code:
    1. for( int row=0; ...)
    2. {
    3. for(int column=0;...)
    4. {
    5.  
    6. myTableWidget.item ( row, column ).setTextAlignment(Qt::AlignCenter);
    7.  
    8. }
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    it only aligns the first - table(0,0) - item but not the rest.
    What could be the problem?

    Thanks in advance
    Last edited by jpn; 15th March 2009 at 10:59. Reason: missing [code] tags

  7. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QTableWidget view problem

    it's done!

    the error was just a minor logical error. The code I posted above is working now.

Similar Threads

  1. Problem inserting in QTableWidget
    By DPinLV in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2006, 00:10
  2. problem with tree view
    By boss_bhat in forum Newbie
    Replies: 4
    Last Post: 4th June 2006, 21:03
  3. Replies: 6
    Last Post: 20th April 2006, 10:23
  4. View update problem
    By prakash in forum Qt Programming
    Replies: 6
    Last Post: 17th March 2006, 10:13
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.