Results 1 to 2 of 2

Thread: Changing only the parent and font-size of QstyledItemDelegate's Editor

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing only the parent and font-size of QstyledItemDelegate's Editor

    I've implemented a class derived from a QStyledItemDelegate so that I can present a custom widget for editing some columns of QSqlTableModel / QTableView. That's working.

    The default editors for most columns are QSpinBoxs. That's fine, except I want them bigger. So, the editor's parent needs to be 0 and the font size needs to be much larger than the default (which sizes nicely to fit in the TableView row, but is too small for touch applications).

    I did this for the columns with custom widgets and could do the same for these other columns. But, is there a way to change only the parent of the default editor and the font point size so I don't have to have totally custom widgets for these too?

    I tried using the QStyleOptionViewItem passed in the virtual QStyledItemDelegate::createEditor method for setting the font size. But it's a const &, so I can't change it in my implementation.

    Thanks,

    Dave Thomas

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing only the parent and font-size of QstyledItemDelegate's Editor

    Quote Originally Posted by davethomaspilot View Post
    I tried using the QStyleOptionViewItem passed in the virtual QStyledItemDelegate::createEditor method for setting the font size. But it's a const &, so I can't change it in my implementation.
    You can create a local copy and modify that.

    Qt Code:
    1. QStyleOptionViewItem myOption = option;
    2. // modify myOption
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    davethomaspilot (11th February 2014)

Similar Threads

  1. Replies: 1
    Last Post: 30th March 2012, 16:46
  2. QLabel Font size is not changing???
    By Gokulnathvc in forum Newbie
    Replies: 4
    Last Post: 22nd March 2011, 11:17
  3. Replies: 1
    Last Post: 3rd December 2009, 15:21
  4. Resizing child widget on changing size of parent?
    By anupamgee in forum Qt Programming
    Replies: 3
    Last Post: 13th November 2009, 08:39
  5. changing QLabel font size(label created on the graphicsView)
    By maverick_pol in forum Qt Programming
    Replies: 11
    Last Post: 17th August 2007, 08: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.