Results 1 to 5 of 5

Thread: HOW TO DISPLAY A RECTANGLE ON AN IMAGE on a label

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default HOW TO DISPLAY A RECTANGLE ON AN IMAGE on a label

    I have already made a video player(it runs different frames according to a timer) on a "QLabel"(not a QScrollArea)......now I have added another functionality that when the "process" button is clicked, the images are displayed along with some rectangles......For this I have used QPainter class's drwaPixel() and drwaRectangle() functions.................but both the functions are not displaying anything on the Label..........Here is the part of the code for the newer(process) functionality..........
    Qt Code:
    1. void VideoDisplayer::processNextPicture()
    2. {
    3.  
    4. if((i >= startFrameMarkerPosition)&&(i < endFrameMarkerPosition))
    5. {
    6. //videoLabel->setPixmap(QPixmap(localFileName.at(i)));
    7. //I used this function for the earlier case(normal video display without process functionality) and it works fine but it can't be used now otherwise the drawRectangle() function doesn't work over it
    8.  
    9. // QFrame::paintEvent(event);
    10.  
    11. QPainter painter(videoLabel);
    12.  
    13. painter.drawPixmap(0,0,400,400,QPixmap(localFileName.at(i)));
    14. //painter.drawPixmap(0,0,100,100,QPixmap(":/images/frame0000.png"));
    15.  
    16. int x,y,w,h;
    17. x=100; y=200; w=80;h=60;
    18. painter.setPen(Qt::red);
    19. painter.drawRect(x,y,w,h);
    20. videoLabel->adjustSize();
    21. //videoLabel->setScaledContents(true);
    22. localSlider->setValue(i);
    23. videoLabel->show();
    24. i++;
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 
    This code displays nothing on the label
    I have also tried using the paintEvent function by defining it with the similar contents and calling it in place of the above code by repaint();This showed me that the paint function is getting called but the drawRectangle() and drawPixmap() on a QLabel are the real culprits.......please suggest a solution......thanx in advance
    Last edited by qt_user; 6th August 2010 at 08:09.

Similar Threads

  1. Replies: 6
    Last Post: 30th July 2010, 07:23
  2. Replies: 1
    Last Post: 23rd May 2009, 09:04
  3. display number on label
    By aj2903 in forum Qt Programming
    Replies: 4
    Last Post: 12th March 2009, 07:24
  4. Display rectangle on Image
    By parmar ranjit in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2008, 13:09
  5. Display a Label on top of a QGlWidget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2008, 16:11

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.