После изменения этой функции с QListViewItem в MyQListViewItem
программа стала зависать при добавлении данных.
void Form1::buildXML( MyQListViewItem *parentItem, QDomElement &parentElement )
{
MyQListViewItem *thisItem;
if ( parentItem )
thisItem = (MyQListViewItem*)parentItem->firstChild();
// thisItem = parentItem->firstChild();
else
thisItem = (MyQListViewItem*)listView2->firstChild();
// thisItem = listView2->firstChild();
QDomDocument doc = parentElement.ownerDocument();
while ( thisItem ) {
QDomElement e = doc.createElement( "item" );
parentElement.appendChild( e );
e.setAttribute( "text", thisItem->text(0));
e.setAttribute( "green", thisItem->getColor().green());
buildXML( thisItem, e );
thisItem = thisItem->nextSibling();
}
}
Не знаю может дело в моём QListViewItem
class MyQListViewItem : public QListViewItem
{
public:
MyQListViewItem( QListView *parent );
MyQListViewItem(QListViewItem * parent);
MyQListViewItem( QListView * parent, QListViewItem * after );
MyQListViewItem( QListViewItem * parent, QListViewItem * after );
~MyQListViewItem();
public:
virtual void paintCell( QPainter* p, const QColorGroup& cg, int column, int width, int align );
QColor getColor() const {return col; };
void setColor( QColor c ) { col = c; }
MyQListViewItem * nextSibling() const { return siblingItem; };
public:
MyQListViewItem * siblingItem;
QColor col;
};
#endif // FORM1_H
//
MyQListViewItem::MyQListViewItem(QListView *parent)
: QListViewItem( parent ){ }
MyQListViewItem::MyQListViewItem(QListViewItem * parent)
: QListViewItem( parent ) { }
MyQListViewItem::MyQListViewItem( QListView * parent, QListViewItem * after )
: QListViewItem( parent , after)
{ }
MyQListViewItem::MyQListViewItem( QListViewItem * parent, QListViewItem * after )
: QListViewItem( parent , after)
{ }
MyQListViewItem::~MyQListViewItem()
{ }
//-----------------------------------------------------------
//MyQListViewItem * MyQListView::findItem ( const QString & text, int column, ComparisonFlags compare = ExactMatch | CaseSensitive ) const
//------------------------------------------------------------
void MyQListViewItem::paintCell( QPainter* p, const QColorGroup& cg, int column, int width, int align )
{
QPen pen = p->pen();
if ( !isSelected() )
p->fillRect( 0, 0, width, height(), QBrush( cg.base() ));
else
p->fillRect( 0, 0, width, height(), QBrush( cg.base() ));
pen.setColor( col );
p->setPen( pen );
p->drawText( 0, 0, width, height(), align, text(column) );
}
Благодарю за помощь.