首页 > 代码库 > Qt无边框,可移动窗口

Qt无边框,可移动窗口




QPoint dragPosition;




void MainWindow::mousePressEvent(QMouseEvent *event)
{
if(event->button()==Qt::LeftButton)
{
dragPosition=event->globalPos()-frameGeometry().topLeft();
event->accept();
}
}
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
if(event->buttons()&&Qt::LeftButton)
{
move(event->globalPos()-dragPosition);
event->accept();
}
}


setStyleSheet("QProgressBar{border:none;background:rgb(210,225,240);border-radius:3px;text-align:center;}QProgressBar::chunk{background:rgb(60,140,220);border-radius:3px;}");