2 Attachment(s)
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.
Attachment 7554
Attachment 7555
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:
Code:
#include <QApplication>
#include <Q3ListView>
int
main( int argc, char* argv[] )
{
Q3ListView w;
w.setRootIsDecorated( true );
w.addColumn( "col1" );
w.show();
Q3ListViewItem* item1 = new Q3ListViewItem( &w, "item1" );
Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
QObject::connect( qApp,
SIGNAL( lastWindowClosed
() ),
qApp,
SLOT( quit
() ) );
return app.exec();
}
Surely I can't be the only person using Q3ListView on Mac? I have searched, but can't find an answer. Any ideas?
Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8
Quote:
Originally Posted by
AndyBrice
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.
Re: Q3ListView expand arrows incorrect on Mac in Qt 4.8
The application is ~7 years old and it still has some Qt3 classes.
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.
Code:
#include <QApplication>
#include <Q3ListView>
#include <Qt3Support>
class A : public Q3ListViewItem {
public:
A
(Q3ListView
*parent,
const QString &label1
) : Q3ListViewItem
(parent, label1
) {} void paintBranches
(QPainter *p,
const QColorGroup
&cg,
int w,
int y,
int h
) { Q3ListViewItem::paintBranches(p, cg, w-7, y, h);
}
};
int main( int argc, char* argv[] )
{
Q3ListView w;
w.setRootIsDecorated( true );
w.addColumn( "col1" );
w.show();
A* item1 = new A( &w, "item1" );
Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
QObject::connect( qApp,
SIGNAL( lastWindowClosed
() ),
qApp,
SLOT( quit
() ) );
return app.exec();
}
1 Attachment(s)
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:
Attachment 7556
Code:
#include <QApplication>
#include <Q3ListView>
class MyListViewItem : public Q3ListViewItem {
public:
MyListViewItem
(Q3ListView
*parent,
const QString &label1
) : Q3ListViewItem
(parent, label1
) {} MyListViewItem
(Q3ListViewItem
*parent,
const QString &label1
) : Q3ListViewItem
(parent, label1
) {} void paintBranches
(QPainter *p,
const QColorGroup
&cg,
int w,
int y,
int h
) { Q3ListViewItem::paintBranches(p, cg, w-7, y, h);
}
};
int
main( int argc, char* argv[] )
{
Q3ListView w;
w.setRootIsDecorated( true );
w.addColumn( "col" );
w.show();
MyListViewItem* item1 = new MyListViewItem( &w, "item1" );
MyListViewItem* item2 = new MyListViewItem( item1, "item2" );
MyListViewItem* item3 = new MyListViewItem( item2, "item3" );
MyListViewItem* item4 = new MyListViewItem( item3, "item4" );
QObject::connect( qApp,
SIGNAL( lastWindowClosed
() ),
qApp,
SLOT( quit
() ) );
return app.exec();
}
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.):
Code:
#include <QtGui>
#include <Q3ListView>
class MyStyle : public QProxyStyle {
public:
{
if (control
== QStyle::CC_Q3ListView) {
oo->rect.adjust(0,0,-7,0);
QProxyStyle::drawComplexControl(control, oo, painter, widget);
}
else
QProxyStyle::drawComplexControl(control, option, painter, widget);
}
};
int
main( int argc, char* argv[] )
{
Q3ListView w;
MyStyle style;
w.setStyle(&style);
w.setRootIsDecorated( true );
w.addColumn( "col" );
w.show();
Q3ListViewItem* item1 = new Q3ListViewItem( &w, "item1" );
Q3ListViewItem* item2 = new Q3ListViewItem( item1, "item2" );
Q3ListViewItem* item3 = new Q3ListViewItem( item2, "item3" );
Q3ListViewItem* item4 = new Q3ListViewItem( item3, "item4" );
QObject::connect( qApp,
SIGNAL( lastWindowClosed
() ),
qApp,
SLOT( quit
() ) );
return app.exec();
}
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