Results 1 to 2 of 2

Thread: How to add lines to desired frame only

  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default How to add lines to desired frame only

    I an developing a game with three frame 1.mainframe 2.gameframe 3.letterframe.
    How can i draw line for the letterframe only.?? for all other frames the Qpainter should be disabled
    waiting for rply. Thanks in advance

  2. #2
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to add lines to desired frame only

    i created a separate class for that particular area.
    but i cant add more than 1line. when i start to draw the second line the first line disappears

    void MainWindow::mousePressEvent(QMouseEvent *e)
    {
    if(e->button()==Qt::LeftButton)
    {
    point = e->pos();
    int tempx=point.rx();
    tempx=tempx/50;
    tempx=(tempx*50)+25;
    int tempy=point.ry();
    tempy=tempy/40;
    tempy=(tempy*40)+20;
    point.setX(tempx);
    point.setY(tempy);
    if(k==0)
    {
    point2=point;
    k=1;
    update();
    return;
    }
    if(k==1)
    k=0;
    update();
    }
    }
    void MainWindow:aintEvent(QPaintEvent *e)
    {
    QPainter painter(this);
    QPen linepen(Qt::red);
    linepen.setWidth(30);
    linepen.setCapStyle(Qt::RoundCap);
    painter.setRenderHint(QPainter::Antialiasing,true) ;
    painter.setPen(linepen);
    if(k==1)
    painter.drawPoint(point);
    else
    painter.drawLine(point,point2);
    }

Similar Threads

  1. How to add mouse area at a desired frame
    By athulms in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2011, 17:26
  2. Replies: 2
    Last Post: 25th March 2011, 04:19
  3. Replies: 0
    Last Post: 15th February 2010, 11:47
  4. Replies: 6
    Last Post: 5th December 2009, 14:46
  5. failing to achieve desired size of a BitField structure
    By nass in forum General Programming
    Replies: 8
    Last Post: 13th February 2007, 13:29

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.