Results 1 to 3 of 3

Thread: Realtion between Qmaindow class and Qpainter class

  1. #1

    Default Realtion between Qmaindow class and Qpainter class

    Are they interdependent
    And how to create a qpainter class object to be used in qmaindow class functions like paintevent()

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Realtion between Qmaindow class and Qpainter class

    Quote Originally Posted by shubham ahir View Post
    Are they interdependent
    Yes.
    One obviously uses the other though.

    Quote Originally Posted by shubham ahir View Post
    And how to create a qpainter class object to be used in qmaindow class functions like paintevent()
    It is not very comon to override QMainWindow:aintEvent(), maybe you want a custom widget as the main window's centralWidget?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2015
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Realtion between Qmaindow class and Qpainter class

    Hi
    as a fast and "dirty" way to paint
    something in main, you can paint on image and show using a QLabel

    int w=200;
    int h=200;
    QPixmap pix(w,h);
    QPainter paint(&pix);
    paint.setBrush(Qt::white);
    paint.drawRect(0,0,w,h);
    paint.setBrush(QBrush(QColor(255,34,255,255)));
    paint.drawRect(0,0,w/2,h/3);
    ui->label->setPixmap(pix);

Similar Threads

  1. Replies: 5
    Last Post: 13th January 2014, 09:24
  2. Replies: 7
    Last Post: 18th August 2011, 14:43
  3. Replies: 30
    Last Post: 12th April 2011, 08:39
  4. Error while redrawing using QPainter Class
    By sosanjay in forum Qt Programming
    Replies: 5
    Last Post: 28th December 2009, 11:48
  5. Replies: 3
    Last Post: 27th December 2008, 19: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.