Results 1 to 14 of 14

Thread: Removing the branches from QListVew...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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

  2. #2
    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

  3. #3
    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: 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() :)

  4. #4
    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

  5. #5
    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!

  6. #6
    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

  7. #7
    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.

  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...

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