PDA

View Full Version : hide image,once moused moved from image



yuvaraj.yadav
22nd April 2009, 05:41
Hi

I have displayed the icons on image,when i am moving the mouse on image,

I need to hide my icons one i moved the mouse apart from the image ....

Here i have used the move move event


my code is



#include "widget.h"
#include "ui_widget.h"

#include <QPainter>

Widget::Widget(QWidget *parent)
: QWidget(parent),
ui(new Ui::WidgetClass),
m_currentImage(0)
{
ui->setupUi(this);

ui->label->setPixmap(QPixmap("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/yuvaraj.png"));
ui->pushButton->hide();
ui->toolButton->hide();
ui->pushButton_2->hide();
ui->toolButton_2->hide();
ui->label->setMouseTracking(true);
ui->label->installEventFilter(this);
}

Widget::~Widget()
{
delete ui;
}

bool Widget::eventFilter(QObject *o, QEvent *e)
{
if (o == ui->label && e->type() == QEvent::MouseMove)
{


QPixmap pixmap(QString("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/yuvaraj.png"));

ui->label->setPixmap(pixmap);
ui->pushButton->show();
ui->toolButton->show();
ui->pushButton_2->show();
ui->toolButton_2->show();
ui->toolButton->setIcon(QIcon("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/raj.png"));
ui->pushButton->setIcon(QIcon("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/raj.png"));
ui->toolButton_2->setIcon(QIcon("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/raj.png"));
ui->pushButton_2->setIcon(QIcon("C:/Documents and Settings/addu.YUVARAJ.001/Desktop/raj.png"));
return true;
}

else
{


return QWidget::eventFilter(o, e);
}
}

void Widget::on_pushButton_clicked()
{
this-close();
}







please suggest me to solve this problem.


Thanks

Yuvaraj R

yuvaraj.yadav
22nd April 2009, 08:16
Hi

I got it ....

I used the Enter and leave events