PDA

View Full Version : QTreeWidgetItem decoration



^NyAw^
26th October 2009, 19:16
Hi,

In QTreeVidget I'm able to change the decoration of the root items with "setRootIsDecorated(false)". The problem is that the children of the root items are still decorated and I can't find the way to disable it.

Thanks,

wysota
26th October 2009, 23:52
Subclass the widget and reimplement QTreeView::drawBranches() leaving the implementation empty.

^NyAw^
27th October 2009, 11:42
Hi,

Thanks wysota.

Another question not really Qt related:
I want to redefine the method you told, but I don't want to create another h and cpp files so I want to add the redefinition in myClass.h:

myClass.h


#ifndef MYCLASS_H
#define MYCLASS_H

class myClass : public QObject
{
Q_OBJECT

public:
myClass(QWidget*);
~myClass();
private:
...
...
}
#endif


Can you tell me how to add the redefinition in the same h file?

Thanks,

wysota
27th October 2009, 11:46
You can declare more than one class in a single .h file. In fact you can write your whole application in a single file.

^NyAw^
27th October 2009, 13:06
Hi,

I have problems on this code. The linker returns LNK2019 error:


myApp error LNK2019: sÃ*mbolo externo "public: __thiscall QTreeWidget2::QTreeWidget2(class QWidget *)" (??QTreeWidget2@@QAE@PAVQWidget@@@Z) sin resolver al que se hace referencia en la función "public: __thiscall myClass::myClass(class QWidget *,class myApp &)" (??0myClass@@QAE@PAVQWidget@@AAVmyApp@@@Z)


myClass.h


#ifndef MYCLASS_H
#define MYCLASS_H

class myClass : public QObject
{
Q_OBJECT

public:
myClass(QWidget*);
~myClass();
private:
...
...
};
#endif //MYCLASS_H

#ifndef QTREEWIDGET2_H
#define QTREEWIDGET2_H

#include <QTreeWidget>
#include <QPainter>
#include <QRect>
#include <QModelIndex>

class QTreeWidget2 : public QTreeWidget
{
Q_OBJECT

public:
QTreeWidget2 (QWidget * parent = 0);
~QTreeWidget2 ();
void drawBranches(QPainter* painter,const QRect& rect,const QModelIndex& index) const {;}; //Don't want to paint the branches
};
#endif //QTREEWIDGET2_H


What I'm donig wrong?

Thanks,

wysota
27th October 2009, 13:25
The linker claims you didn't implement the constructor for your tree widget class.

^NyAw^
27th October 2009, 16:01
Hi,

Thank you very much.:)