Results 1 to 3 of 3

Thread: How to get the padding or margins set in style sheet?

  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question How to get the padding or margins set in style sheet?

    Hi, all.
    foi set some widget's padding and margins in a style sheet. and how can i get it in my code? for example, i write:
    Qt Code:
    1. QTableView::item{
    2. padding:10px;
    3. margins:10px;
    4. border:1px solid red;
    5. border-radius:5px;
    6. }
    To copy to clipboard, switch view to plain text mode 

    and i reimplement
    Qt Code:
    1. QStyledItemDelegate::(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
    To copy to clipboard, switch view to plain text mode 
    , i want the padding and margins of this item here, what shall i do?

    i wonder item's padding and margins since i want to put html-text in the item, and paint the html-text by self when implementing paint(), however, i have to translate correctly to the rect that text should be displayed, or else, the text might be overlapped with the borders.

    Thank you.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get the padding or margins set in style sheet?

    If you are using delegates, you get rect in const QStyleOptionViewItem &option argument.
    option.rect() [QStyleOption::rect ]
    Hope this helps

  3. #3
    Join Date
    Apr 2015
    Posts
    9
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to get the padding or margins set in style sheet?

    option.rect gives you just the rect including the padding. Any solution to this?

Similar Threads

  1. QMenu style sheet: works in dev env, breaks in release
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2008, 19:18
  2. style sheet issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2008, 07:18
  3. Style Sheet on QWizard
    By desch in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2007, 17:12
  4. QToolButton and Style sheet
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 1st December 2007, 08:38
  5. Qt 4.3 Style sheet, new features
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2007, 15:22

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.