Results 1 to 7 of 7

Thread: Q3ListView expand arrows incorrect on Mac in Qt 4.8

  1. #1
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Q3ListView expand arrows incorrect on Mac in Qt 4.8

    The expand/collapse arrows for Q3ListView look wrong on Mac OS X. See attached Windows and Mac screenshots.

    listview_windows.png

    listview_mac.png

    In the Mac screenshot the expand/collapse arrows are partly obscured by the Q3ListViewItems. It looks quite wrong. The problem also exists in Qt 4.7, but not in Qt 4.2 (I haven't tried releases in between).

    Here is the code to replicate the problem:

    Qt Code:
    1. #include <QApplication>
    2. #include <Q3ListView>
    3. int
    4. main( int argc, char* argv[] )
    5. {
    6. QApplication app( argc, argv );
    7.  
    8. Q3ListView w;
    9. w.setRootIsDecorated( true );
    10. w.addColumn( "col1" );
    11. w.show();
    12.  
    13. Q3ListViewItem* item1 = new Q3ListViewItem( &w, "item1" );
    14. Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
    15. Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
    16.  
    17. QObject::connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
    18.  
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

    Surely I can't be the only person using Q3ListView on Mac? I have searched, but can't find an answer. Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    Quote Originally Posted by AndyBrice View Post
    Surely I can't be the only person using Q3ListView on Mac?
    OT, but I hope you are! Qt5 is coming soon, Qt4 is out for years and you still deal with Qt3? Is that a new application?


    On my mac it also looks corrupted. You can try to write a custom delegate to adjust the position.

  3. #3
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    The application is ~7 years old and it still has some Qt3 classes.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    Did I wrote delegate... This adjust the arrow of item 2. Not nice, but a quick workaround.
    Qt Code:
    1. #include <QApplication>
    2. #include <Q3ListView>
    3. #include <Qt3Support>
    4.  
    5.  
    6. class A : public Q3ListViewItem {
    7. public:
    8. A(Q3ListView *parent, const QString &label1) : Q3ListViewItem(parent, label1) {}
    9. void paintBranches(QPainter *p, const QColorGroup &cg, int w, int y, int h) {
    10. Q3ListViewItem::paintBranches(p, cg, w-7, y, h);
    11. }
    12. };
    13.  
    14.  
    15. int main( int argc, char* argv[] )
    16. {
    17. QApplication app( argc, argv );
    18.  
    19. Q3ListView w;
    20. w.setRootIsDecorated( true );
    21. w.addColumn( "col1" );
    22. w.show();
    23.  
    24. A* item1 = new A( &w, "item1" );
    25. Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
    26. Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
    27.  
    28. QObject::connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
    29.  
    30. return app.exec();
    31. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    Lykurg,

    A quick workaround is just fine! I tried your solution and it works fine for items with parents. But the root items still look wrong. Do you know where the expand/collapse arrow for the root item get drawn, in Q3ListViewItem::paintCell()?


    Added after 5 minutes:


    Here you can see the root item still doesn't look correct:

    listview2.png

    Qt Code:
    1. #include <QApplication>
    2. #include <Q3ListView>
    3.  
    4. class MyListViewItem : public Q3ListViewItem {
    5. public:
    6. MyListViewItem(Q3ListView *parent, const QString &label1) : Q3ListViewItem(parent, label1) {}
    7. MyListViewItem(Q3ListViewItem *parent, const QString &label1) : Q3ListViewItem(parent, label1) {}
    8. void paintBranches(QPainter *p, const QColorGroup &cg, int w, int y, int h) {
    9. Q3ListViewItem::paintBranches(p, cg, w-7, y, h);
    10. }
    11. };
    12.  
    13. int
    14. main( int argc, char* argv[] )
    15. {
    16. QApplication app( argc, argv );
    17.  
    18. Q3ListView w;
    19. w.setRootIsDecorated( true );
    20. w.addColumn( "col" );
    21. w.show();
    22.  
    23. MyListViewItem* item1 = new MyListViewItem( &w, "item1" );
    24. MyListViewItem* item2 = new MyListViewItem( item1, "item2" );
    25. MyListViewItem* item3 = new MyListViewItem( item2, "item3" );
    26. MyListViewItem* item4 = new MyListViewItem( item3, "item4" );
    27.  
    28. QObject::connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
    29.  
    30. return app.exec();
    31. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by AndyBrice; 4th April 2012 at 00:22.

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    Ahh, it is a private Q3ListViewItem which is hard to reach. So forget all I have said and do it this way (which don't need much changes.):

    Qt Code:
    1. #include <QtGui>
    2. #include <Q3ListView>
    3.  
    4. class MyStyle : public QProxyStyle {
    5. public:
    6. void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
    7. {
    8. if (control == QStyle::CC_Q3ListView)
    9. {
    10. QStyleOptionComplex *oo = const_cast<QStyleOptionComplex*>(option);
    11. oo->rect.adjust(0,0,-7,0);
    12. QProxyStyle::drawComplexControl(control, oo, painter, widget);
    13. }
    14. else
    15. QProxyStyle::drawComplexControl(control, option, painter, widget);
    16.  
    17. }
    18. };
    19.  
    20. int
    21. main( int argc, char* argv[] )
    22. {
    23. QApplication app( argc, argv );
    24.  
    25.  
    26. Q3ListView w;
    27.  
    28. MyStyle style;
    29. w.setStyle(&style);
    30.  
    31. w.setRootIsDecorated( true );
    32. w.addColumn( "col" );
    33. w.show();
    34.  
    35. Q3ListViewItem* item1 = new Q3ListViewItem( &w, "item1" );
    36. Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
    37. Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
    38. Q3ListViewItem* item4 = new Q3ListViewItem( item3, "item4" );
    39.  
    40. QObject::connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
    41.  
    42. return app.exec();
    43. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Lykurg for this useful post:

    AndyBrice (4th April 2012)

  8. #7
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8

    That seems to work perfectly. Much appreciated!

    best regards

    Andy Brice
    http://www.perfecttableplan.com
    http://www.successfulsoftware.net

Similar Threads

  1. Values of a Q3ListView
    By martisho in forum Qt Programming
    Replies: 0
    Last Post: 13th November 2009, 13:21
  2. How to use Q3Listview in Qt-4.2.1
    By grsandeep85 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2009, 07:04
  3. Q3ListView
    By grsandeep85 in forum Qt Programming
    Replies: 0
    Last Post: 31st August 2009, 12:40
  4. Q3ListView not being populated.
    By user_mail07 in forum Qt Programming
    Replies: 7
    Last Post: 19th March 2007, 15:54
  5. Q3ListView
    By kemp in forum Qt Programming
    Replies: 6
    Last Post: 9th October 2006, 08:58

Tags for this Thread

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.