Results 1 to 4 of 4

Thread: QStyledItemDelegate not working cross platform

  1. #1
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QStyledItemDelegate not working cross platform

    I am using Qt 5.1.1 and have a QListView with a custom QStyledItemDelegate inside a Widget with the Qt::Popup flag to make a special dropdown in my app.


    Qt Code:
    1. void MyCustomItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. qDebug() << option.state;
    4. }
    To copy to clipboard, switch view to plain text mode 

    On Windows 7 everything works fine and the flags from the QStyleOptionViewItem are as expected, my app renders a nice list that reacts to MouseOver & Selected

    Qt Code:
    1. ..
    2. QStyle::State( "Enabled | Selected" )
    3. QStyle::State( "Enabled" )
    4. QStyle::State( "Enabled | MouseOver" )
    5. QStyle::State( "Enabled" )
    6. ...
    To copy to clipboard, switch view to plain text mode 

    HOWEVER on Linux and Windows XP the flags are not as expected - MouseOver state is never set and all Items are receiving Active

    Qt Code:
    1. ...
    2. QStyle::State( "Active | Enabled | HasFocus | Selected" )
    3. QStyle::State( "Active | Enabled" )
    4. QStyle::State( "Active | Enabled" )
    5. QStyle::State( "Active | Enabled" )
    6. ...
    To copy to clipboard, switch view to plain text mode 

    Is this expected? Is there a work around (besides checking if the cursor is within option.rect every time)
    Last edited by Berryblue031; 24th September 2013 at 07:04.

  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: QStyledItemDelegate not working cross platform

    Might be more related to the style being used than to the delegate.
    Which style are you using on, e.g. Linux? Have you tried a different one?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QStyledItemDelegate not working cross platform

    I don't see how the style would affect the state flags? It's works the other way around doesn't it? Depending on the state flags the style will choose how to render?

    On Linux and Windows XP I am using the default styles - if I wasn't using a custom delegate for painting and was just styling the QListViewItems in the stylesheets with QListView::item:hover all platforms would work fine so it should be possible to detect hover even on other platforms.

  4. #4
    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: QStyledItemDelegate not working cross platform

    Styles can do active things as well, e.g. listen to events and triggering changes, etc.

    They are the most likely cause when something is different visualization wise.
    What happens if you run the application on Windows 7 but using the Windows XP style?

    Cheers,
    _

Similar Threads

  1. Are there any other cross-platform framework like Qt?
    By grayfox in forum Qt Programming
    Replies: 1
    Last Post: 11th July 2011, 17:19
  2. Replies: 1
    Last Post: 11th November 2010, 00:31
  3. Cross-platform GUI app
    By rockballad in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2010, 07:38
  4. Qt's Cross-Platform Functionality
    By winston2020 in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2009, 18:31
  5. Cross Platform Logging
    By skyphyr in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2006, 16:32

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.