Results 1 to 7 of 7

Thread: QTreeWidgetItem decoration

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QTreeWidgetItem decoration

    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,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidgetItem decoration

    Subclass the widget and reimplement QTreeView::drawBranches() leaving the implementation empty.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidgetItem decoration

    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
    Qt Code:
    1. #ifndef MYCLASS_H
    2. #define MYCLASS_H
    3.  
    4. class myClass : public QObject
    5. {
    6. Q_OBJECT
    7.  
    8. public:
    9. myClass(QWidget*);
    10. ~myClass();
    11. private:
    12. ...
    13. ...
    14. }
    15. #endif
    To copy to clipboard, switch view to plain text mode 

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

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidgetItem decoration

    You can declare more than one class in a single .h file. In fact you can write your whole application in a single file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidgetItem decoration

    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
    Qt Code:
    1. #ifndef MYCLASS_H
    2. #define MYCLASS_H
    3.  
    4. class myClass : public QObject
    5. {
    6. Q_OBJECT
    7.  
    8. public:
    9. myClass(QWidget*);
    10. ~myClass();
    11. private:
    12. ...
    13. ...
    14. };
    15. #endif //MYCLASS_H
    16.  
    17. #ifndef QTREEWIDGET2_H
    18. #define QTREEWIDGET2_H
    19.  
    20. #include <QTreeWidget>
    21. #include <QPainter>
    22. #include <QRect>
    23. #include <QModelIndex>
    24.  
    25. class QTreeWidget2 : public QTreeWidget
    26. {
    27. Q_OBJECT
    28.  
    29. public:
    30. QTreeWidget2 (QWidget * parent = 0);
    31. ~QTreeWidget2 ();
    32. void drawBranches(QPainter* painter,const QRect& rect,const QModelIndex& index) const {;}; //Don't want to paint the branches
    33. };
    34. #endif //QTREEWIDGET2_H
    To copy to clipboard, switch view to plain text mode 

    What I'm donig wrong?

    Thanks,
    Last edited by wysota; 27th October 2009 at 12:26.
    Òscar Llarch i Galán

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidgetItem decoration

    The linker claims you didn't implement the constructor for your tree widget class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidgetItem decoration

    Hi,

    Thank you very much.
    Òscar Llarch i Galán

Similar Threads

  1. hidden a QTreeWidgetItem
    By mattia in forum Newbie
    Replies: 6
    Last Post: 19th February 2014, 14:04
  2. Custom QTreeWidgetItem context menu?
    By AaronMK in forum Qt Programming
    Replies: 4
    Last Post: 1st February 2010, 04:42
  3. PyQt remove the current QTreeWidgetItem
    By koenux in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2009, 23:08
  4. Replies: 3
    Last Post: 26th April 2008, 18:42
  5. QTreeWidgetItem swap or move up one level problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 18:34

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
  •  
Qt is a trademark of The Qt Company.