[Qt-interest] problem in mouseEvent
chandrasekar wagmare
sekarwagmare at gmail.com
Thu Apr 9 12:40:22 CEST 2009
thanks .. i eill first try test case ...
On Thu, Apr 9, 2009 at 2:05 PM, Srdjan Todorovic <todorovic.s at googlemail.com
> wrote:
> Hi,
>
> 2009/4/8 chandrasekar wagmare <sekarwagmare at gmail.com>:
> > hi friends,
> > i post my entire program here ... can any one please help me to
> solve
> > the problem
>
> It's not the entire program - where's main() ? ;-)
>
> > ToolTipper::ToolTipper(QWidget *parent)
> > :QWidget(parent ,Qt::ToolTip)
> > {
> > QString path = "<font color =red>The communication failed due to
> > heavy rain all network jammed </font>";
> >
> > label = new QLabel();
> > label2 = new QLabel();
> > label2->setGeometry(QRect(0, 0, 116, 121));
> >
> >
> label2->setPixmap(QPixmap(QString::fromUtf8(":/images/closeButton2.png")));
> > label2->setScaledContents(true);
> > label->setText(path);
> > QHBoxLayout *horizontalLayout = new QHBoxLayout();
> > horizontalLayout->addWidget(label);
> > horizontalLayout->addWidget(label2);
> > QVBoxLayout *verticalLayout = new QVBoxLayout();
> > verticalLayout->addLayout(horizontalLayout);
> > setLayout(verticalLayout);
> > layout()->setSizeConstraint(QLayout::SetFixedSize);
> > }
> >
> > void ToolTipper::mousePressEvent(QMouseEvent *event)
> > {
> > if(event->button() == Qt::LeftButton){
> > printf("label2of x() %d and event y() %d \n", label2->x(),
> > label2->y());
> > checkClicked(event->pos());
> > }else{
> > QWidget::mousePressEvent(event);
> > return ;
> > }
> > }
> > void ToolTipper::checkClicked( const QPoint &pos)
> > {
> > int i = pos.x();
> > int j = pos.y();
>
> Have you checked (printed) that i and j are values that you expect
> (ie. within the label's qrect)?
>
>
> > if(label->rect().contains(i , j)){
>
> Have you checked that label->rect() is a QRect that you expect?
>
> Maybe write a unit test so that you know what the code is doing.
>
> > printf("the position is inside ...\n");
> > }else{
> > printf("no its not working ...\n");
> > }
> >
> > }
>
> Hope that helps,
>
> Srdjan
>
--
CHANDRU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090409/cddd6545/attachment.html
More information about the Qt-interest-old
mailing list