×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    7

    How to draw fillrect using QGraphicsRectItem

    hi all,

    I need to draw filled rect using QGraphicsRectItem on QGraphicsScene.

    Please help me...

    regards,
    Manju

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to draw fillrect using QGraphicsRectItem

    Just do it?
    Code:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QGraphicsRectItem>
    
    int
    main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QGraphicsScene scene;
        QGraphicsView view(&scene);
    
        QGraphicsRectItem rect(QRectF(0,0, 50, 50));
        rect.setBrush(QBrush(Qt::darkRed));
        rect.setPen(QPen(Qt::darkGreen));
        scene.addItem(&rect);
    
        view.show();
    
        return app.exec();
    }

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    1

    Re: How to draw fillrect using QGraphicsRectItem

    FYI: To draw a filled QGraphicsRectItem I also had to set the Style to a solid pattern.

    QBrush b;
    b.setColor( Qt::blue );//*backgroundColor );//rectColor );
    b.setStyle( Qt::SolidPattern);
    rect->setBrush(b);

    otherwise it wouldn't draw a filled rect.

Similar Threads

  1. View server panic with 11 on draw
    By raj_rr7 in forum Symbian User Interface
    Replies: 7
    Last Post: 2009-05-18, 11:36
  2. Draw function
    By praveenp in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-10-17, 12:27
  3. why can i not draw line in Draw()?
    By isarc in forum Symbian
    Replies: 7
    Last Post: 2008-05-13, 10:51
  4. Replies: 0
    Last Post: 2008-04-15, 08:38
  5. Replies: 2
    Last Post: 2007-04-04, 02:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×