Qt Code:
  1. QDesktopWidget *desktop = QApplication::desktop();
  2. screenWidth1 = desktop->width();
  3. screenHeight1 = desktop->height();
  4. x1 = screenWidth1-400;
  5. y1 = screenHeight1-675;
  6. QTimer *cursor_Pos = new QTimer(this);
  7. connect(cursor_Pos, SIGNAL(timeout()), this, SLOT(updatePos()));
  8. cursor_Pos->setInterval(250);
  9. cursor_Pos->start();
  10.  
  11. void RightSideBar::updatePos()
  12. {
  13. dr = QApplication::desktop()->rect();
  14. QPoint mp = QCursor::pos();
  15. int cursor_check;
  16. cursor_check=QApplication::desktop()->width()-this->width();
  17. if( mp.x() > dr.right() - 10&&this->isVisible()&&cursorRight==true)
  18. {
  19. qDebug()<<"Cursor on Right Edge of desktop!!!";
  20. cursorRight=false;
  21. cursorLeft=true;
  22. widgetRight=true;
  23.  
  24. this->setGeometry(x1+52,y1,340,screenHeight1-200);
  25.  
  26. }
  27. if(this->width()+this->x()>dr.right() - 10&&this->isVisible()&&widgetRight==true)
  28. {
  29. qDebug()<<"Widget on Right Edge of desktop!!!";
  30. widgetRight=false;
  31. cursorRight=true;
  32. this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
  33.  
  34.  
  35. }
  36. if(cursor_check>mp.x()&&this->isVisible()&&cursorLeft==true)
  37. {
  38. qDebug()<<"Cursor Position is less then Widget Position";
  39. cursorLeft=false;
  40. cursorRight=true;
  41. this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
  42.  
  43. }
  44.  
  45. }
To copy to clipboard, switch view to plain text mode 

First and third conditions are working fine in our application.In this code second condition is not working properly.How can we rectify the issues?