screenWidth1 = desktop->width();
screenHeight1 = desktop->height();
x1 = screenWidth1-400;
y1 = screenHeight1-675;
connect(cursor_Pos, SIGNAL(timeout()), this, SLOT(updatePos()));
cursor_Pos->setInterval(250);
cursor_Pos->start();
void RightSideBar::updatePos()
{
int cursor_check;
cursor_check
=QApplication::desktop()->width
()-this
->width
();
if( mp.x() > dr.right() - 10&&this->isVisible()&&cursorRight==true)
{
qDebug()<<"Cursor on Right Edge of desktop!!!";
cursorRight=false;
cursorLeft=true;
widgetRight=true;
this->setGeometry(x1+52,y1,340,screenHeight1-200);
}
if(this->width()+this->x()>dr.right() - 10&&this->isVisible()&&widgetRight==true)
{
qDebug()<<"Widget on Right Edge of desktop!!!";
widgetRight=false;
cursorRight=true;
this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
}
if(cursor_check>mp.x()&&this->isVisible()&&cursorLeft==true)
{
qDebug()<<"Cursor Position is less then Widget Position";
cursorLeft=false;
cursorRight=true;
this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
}
}
QDesktopWidget *desktop = QApplication::desktop();
screenWidth1 = desktop->width();
screenHeight1 = desktop->height();
x1 = screenWidth1-400;
y1 = screenHeight1-675;
QTimer *cursor_Pos = new QTimer(this);
connect(cursor_Pos, SIGNAL(timeout()), this, SLOT(updatePos()));
cursor_Pos->setInterval(250);
cursor_Pos->start();
void RightSideBar::updatePos()
{
dr = QApplication::desktop()->rect();
QPoint mp = QCursor::pos();
int cursor_check;
cursor_check=QApplication::desktop()->width()-this->width();
if( mp.x() > dr.right() - 10&&this->isVisible()&&cursorRight==true)
{
qDebug()<<"Cursor on Right Edge of desktop!!!";
cursorRight=false;
cursorLeft=true;
widgetRight=true;
this->setGeometry(x1+52,y1,340,screenHeight1-200);
}
if(this->width()+this->x()>dr.right() - 10&&this->isVisible()&&widgetRight==true)
{
qDebug()<<"Widget on Right Edge of desktop!!!";
widgetRight=false;
cursorRight=true;
this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
}
if(cursor_check>mp.x()&&this->isVisible()&&cursorLeft==true)
{
qDebug()<<"Cursor Position is less then Widget Position";
cursorLeft=false;
cursorRight=true;
this->setGeometry(this->width()+this->x()*2,this->y(),340,screenHeight1-200);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks