Results 1 to 14 of 14

Thread: Removing the branches from QListVew...

  1. #1
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Removing the branches from QListVew...

    I have spent a lot of time trying to remove the branches off the listview but have been unsuccesfull till now. I am usin free qt 3.3.4. I guess there is a virtual function called paintBrances(,,,,) with several parameters...Does anyone know how we can apply the QPainter along with other parametere of this function so that the branches could be removed..
    I would have tried harder...but I don't want to waste much time in it..so if anyone has already removed the dotted branches of the Listview please help..

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

    Default Re: Removing the branches from QListVew...

    Reimplement that function and leave it blank. It should work

  3. #3
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    Well.. I tried and it didn't work..
    I first tried wtih
    void ListView::drawContentsOffset ( QPainter * p, int ox, int oy, int cx, int cy, int cw, int ch )
    {

    }

    which had no effect... and also tried with the paintBranches function...but no luck..

    Well..it seems that I had to change the Wdiget style through setStyle...digging into it right now

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

    Default Re: Removing the branches from QListVew...

    I don't see a paintBranches method in Qt3 QListView...

    Aa... it's in QListViewItem... Reimplementing it and leaving it blank should certainly work...

  5. #5
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    well I don't like pasting codes...but I don't know what I am doing wrong. The code seems to compile correctly but the branches are still there...here is the code..I have made QListView in the Qt Designer.

    void ListView::init()
    {
    mainList->setRootIsDecorated(TRUE);
    QHeader *head=mainList->header();
    head->hide();
    // mainList->setTreeStepSize(40);
    setGroups("A",10);
    setGroups("B",10);
    setGroups("C",20);
    setGroups("D",20);

    }


    void ListView::setGroups(QString label,int items)
    {

    QListViewItem *grpItem=new QListViewItem(mainList,label);
    mainList->setTreeStepSize(25);
    // mainList->setStyle(QStyle::SC_ListViewBranch);
    for(int i=0;i<items;i++)
    {
    new QListViewItem(grpItem,"Listings");
    }

    }

    void ListView:aintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h )
    {
    }


    even tried with
    void paintBranches( QPainter * p, const QColorGroup & cg, int w, int y, int h )
    {
    }

    compiled correctly but no desired output..

    well I tried drawContentsOffset() in the similar manner and in the manual it says that that function of QListView will call paintBranches..in either case no luck..
    Do I need to be using QStyle for this ??
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

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

    Default Re: Removing the branches from QListVew...

    But paintBranches should be reimplemented in the item not in the view!

    Qt Code:
    1. class MyListViewItem : public QListViewItem{
    2. //...
    3. void paintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h ){}
    4. };
    5.  
    6. //...
    7. void ListView::setGroups(QString label,int items)
    8. {
    9. MyListViewItem *grpItem=new MyListViewItem(mainList,label);
    10. //...
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    I didn't think it would take this much of time..however finally I got the branches to be removed . But the problem isn't solved...it seems that the ListView is not repainting it in somewhat and I have tried using it at various places but all attempts failed..

    I have added a picture which might give a better picture.(The unwanted part that hasn't been repainted has been circled with red).

    However, if I minimize the whole application and then maximize then the widget gets repainted again...

    Also if someone might help to remove the still remaining dotted lines that are in the list..(refer to the picture)
    Attached Images Attached Images
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

  8. #8
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    Also could anyone tell the functions that are called when a mainWindow is minimized and maximized. If I could reimplement the painting functions that are called during maximization of a widget may be I could solve this problem..
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

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

    Default Re: Removing the branches from QListVew...

    Quote Originally Posted by ct
    Also could anyone tell the functions that are called when a mainWindow is minimized and maximized. If I could reimplement the painting functions that are called during maximization of a widget may be I could solve this problem..
    QWidget::paintEvent() :)

  10. #10
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    Finally, got rid of all the branches in the ListView . By creating a style and re-implementing the drawComplexControl function as I have done below we can easily remove the branches.

    #include <qwindowsstyle.h>
    #include <qstyle.h>
    #include<qpainter.h>
    #include<qpixmap.h>
    #include<qlistview.h>

    class ListStyleublic QWindowsStyle
    {
    Q_OBJECT

    public:
    ListStyle();
    ~ListStyle();

    void drawComplexControl ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, SFlags how = Style_Default, SCFlags sub = SC_All, SCFlags subActive = SC_None, const QStyleOption & opt = QStyleOption:efault ) const ;
    private:
    // Disabled copy constructor and operator=
    ListStyle( const ListStyle & );
    ListStyle& operator=( const ListStyle & );
    };



    ListStyle::ListStyle()
    {
    }


    ListStyle::~ListStyle()
    {


    }

    void ListStyle::drawComplexControl ( ComplexControl control, QPainter * p,
    const QWidget * widget, const QRect & r, const QColorGroup & cg,
    SFlags how , SCFlags sub ,
    SCFlags subActive , const QStyleOption & opt ) const
    {
    if((sub & SC_ListViewBranch))
    {

    }
    else
    QWindowsStyle::drawComplexControl(control,p,widget ,r,cg,how,sub,subActive,opt);
    }
    after making this we just need to set the style for the listview widget like
    myListView->setStyle(new ListStyle());


    Just posted it so that no one ever has to waste a lotttt of time as I did digging into this minor detail....
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

  11. #11
    Join Date
    Mar 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    Hi,

    I am having a similar problem... I don't want to draw the dotted branch lines, but I do want to draw the little collapse/expand square next to the items that contain children... does anyone have any ideas on how I can accomplish that?

    Thanks!

  12. #12
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Removing the branches from QListVew...

    Quote Originally Posted by jatoro46
    Hi,

    I am having a similar problem... I don't want to draw the dotted branch lines, but I do want to draw the little collapse/expand square next to the items that contain children... does anyone have any ideas on how I can accomplish that?

    Thanks!
    take a look at this thread
    http://www.qtcentre.org/forum/showth...light=branches

  13. #13
    Join Date
    Mar 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    thank you for your input. Unfortunately, I am using Qt 3.3.5 and this example is only good for Qt4. I appreciate the suggestion though.

  14. #14
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing the branches from QListVew...

    Hi,

    I am having a similar problem... I don't want to draw the dotted branch lines, but I do want to draw the little collapse/expand square next to the items that contain children... does anyone have any ideas on how I can accomplish that?

    Thanks!
    well I have already pasted the code for removing ALL the branches. Now as for the square is concerned, you can create a small + and - square pixmap and put the pixmap on QListViewItem. Then all you need to do is catch a single or double click on the QListViewItem and change the pixmap according to whether the item is open or closed. Qt 3.3.4 has those functions I guess (and 3.3.5 will have it if I am not wrong). Now make those QListViewItem having +,- pixmaps as parents for all other QListViewItems and you are set to go..
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

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.