Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: How do draw a frame in QListView?

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

    Default Re: How do draw a frame in QListView?

    Can we see the code along with the class declaration?

  2. #22
    Join Date
    Dec 2006
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: How do draw a frame in QListView?

    Qt Code:
    1. class myView : public QListView
    2. {
    3. Q_OBJECT
    4. public:
    5. myView(QWidget *parent = 0);
    6. protected:
    7. void paintEvent(QPaintEvent *event);
    8. private:
    9.  
    10. };
    11.  
    12. myView::myView(QWidget *parent)
    13. : QListView(parent)
    14. {
    15. }
    16.  
    17. void myView::paintEvent(QPaintEvent *event)
    18. {
    19. QPainter painter(this);
    20. QPen pen(Qt::green, 10, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    21. painter.setPen(pen);
    22. painter.drawRect(rect());
    23. QListView::paintEvent(event);
    24. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: How do draw a frame in QListView?

    The code looks correct. You don't call the paintEvent yourself, do you?

  4. #24
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How do draw a frame in QListView?

    It should be:
    Qt Code:
    1. QPainter painter(viewport());
    To copy to clipboard, switch view to plain text mode 

    Which is mentioned in the docs QAbstractScrollArea::paintEvent():
    Note: If you open a painter, make sure to open it on the viewport().
    J-P Nurmi

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

    Default Re: How do draw a frame in QListView?

    Oh, it's a listview! I somehow thought we were talking about QFrame Silly me...

Similar Threads

  1. Replies: 0
    Last Post: 10th November 2006, 13:46
  2. Using QGLWidget paint engine to draw regular widgtes?
    By high_flyer in forum Qt Programming
    Replies: 11
    Last Post: 9th October 2006, 12:06
  3. Replies: 16
    Last Post: 7th March 2006, 15:57
  4. Multi frame management ... is it possible ?
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 25th January 2006, 10:41
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 14:45

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.