Results 1 to 2 of 2

Thread: Pushbutton in delegate with icon - left margin problem

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Pushbutton in delegate with icon - left margin problem

    Hello,
    I have a problem with painting pushbutton with icon in delegate. The problem is that when I pain Icon with pushbutton left margin/"left position value" is set to 0 = left side of the column in view, but when I don't paint Icon everything is good and I can set left margin to some other value i.e. 10 (with is equal to left value of the CE_PushButton).
    The painting looks like this:
    Qt Code:
    1. pb_Style.state = option.state;
    2. pb_Style.rect = option.rect;
    3. // pb_Style.icon = QIcon( ":/icon.png" );
    4. // pb_Style.iconSize = QSize( 12, 12 );
    5.  
    6. /** when Icon is drawn delegate calculate wrong left pos with is equal to the row left */
    7. QApplication::style()->drawControl( QStyle::CE_PushButton, &pb_Style, painter );
    To copy to clipboard, switch view to plain text mode 

    The result is this: deleg.JPG , icon is painted all the way to the left row pos, but what I want is to paint it to left pos of the pushbutton (CE_PushButton).
    The problem is probably that I don't pas rect for the Icon properly but...

    Thanks for any help
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Pushbutton in delegate with icon - left margin problem

    Maybe I wasn't clear enough, icon is painted (when resizing) way back to 0 pos (relative to row left pos = 0 pos of icon) but CE_PushButton maintain left margin (i.e. 10 pixels) so what You see in above image is after resizing column.
    Any suggestions are more then welcome because I struggle with this for a long time.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Icon margin in QListView
    By mpi in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2010, 13:56
  2. PushButton Icon Location
    By jftaylor21 in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 16:46
  3. left alignment for pushbutton text
    By BalaQT in forum Qt Programming
    Replies: 7
    Last Post: 22nd September 2009, 08:41
  4. add an icon to a pushbutton
    By sophister in forum Qt Programming
    Replies: 8
    Last Post: 25th June 2009, 10:50
  5. How to get pushbutton as an icon
    By Pembar in forum Newbie
    Replies: 1
    Last Post: 12th May 2009, 19:59

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.