You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include "flyme/flyme.h"
# include "ui_flyme.h"
# include <QDesktopWidget>
# include <QDebug>
FloatingButton : : FloatingButton ( QWidget * parent )
: QPushButton ( parent )
{
FloatingButton_init ( ) ;
}
FloatingButton : : ~ FloatingButton ( )
{
}
void FloatingButton : : FloatingButton_init ( )
{
// 设置悬浮球按钮的大小和位置
setGeometry ( QRect ( 725 , 200 , 80 , 80 ) ) ;
setIcon ( QIcon ( " :/icon/flow_set.png " ) ) ;
setIconSize ( QSize ( 80 , 80 ) ) ;
// 设置不透明度
setWindowOpacity ( 0.95 ) ;
// 隐藏边框
setFlat ( true ) ;
// 设置窗口标志为窗口置顶
setWindowFlags ( Qt : : WindowStaysOnTopHint | Qt : : FramelessWindowHint ) ;
// // 将悬浮球放置在屏幕的中心位置
// QRect screenGeometry = QApplication::desktop()->screenGeometry();
// int x = (screenGeometry.width() - width())-50;
// int y = (screenGeometry.height() - height()) / 2-25;
// move(x, y);
}
void FloatingButton : : mousePressEvent ( QMouseEvent * event )
{
if ( event - > button ( ) = = Qt : : LeftButton ) //表示鼠标左键的值
{
// 当悬浮球被按下时, 发射pressed()信号
emit pressed ( ) ;
}
}