Results 1 to 3 of 3

Thread: Set the border's color/style/width of a specified cell in the QTableWidget

  1. #1
    Join Date
    Jul 2013
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Smile Set the border's color/style/width of a specified cell in the QTableWidget

    Hi all,how to set the border's color/style/width of a specified cell in the QTableWidget?

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

    Default Re: Set the border's color/style/width of a specified cell in the QTableWidget

    You set the row/column width/height by calling QHeaderView::resizeSection() on the horizontalHeader()/verticalheader(). You can have them resize themselves in various ways by using QHeaderView::setResizeMode().

    The background, text alignment, font etc. are controlled by data supplied through the model (QTableView) or QTableWidgetItems (QTableWidget). These roles are relevant: Qt::BackgroundRole, Qt::CheckStateRole, Qt::CheckState, Qt:ecorationRole, Qt::FontRole, Qt::TextAlignmentRole, Qt::ForegroundRole

    You can implement borders on a cell (separate from the table grid lines) using a QStyledItemDelegate and its paintEvent().

  3. #3
    Join Date
    Jul 2013
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set the border's color/style/width of a specified cell in the QTableWidget

    You can implement borders on a cell (separate from the table grid lines) using a QStyledItemDelegate and its paintEvent().

    Thanks,I know that we should subclass the QStyleItemDelegate and reimplement the paint() and sizeHint() methods.Since I'm just a beginner of Qt,may you provide me a example program what can set the border's color of the specified cell?

Similar Threads

  1. Border around selected cell in qtablewidget...
    By pyqt123 in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2012, 13:55
  2. QTableWidget cell color on maemo not changing
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2010, 14:04
  3. Replies: 1
    Last Post: 25th May 2010, 14:44
  4. Replies: 1
    Last Post: 7th December 2009, 18:56
  5. Replies: 1
    Last Post: 23rd March 2009, 21:36

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.