Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.Add 4K screen display adaptation;2. Change show application positio… #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
#include <QApplication>
int main(int argc, char *argv[])
{
/*
* 添加4K 屏幕支持。
*/
#if(QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#else
// do not support 4K.
#endif
QApplication a(argc, argv);
MainWindow w;
w.show();
Expand Down
14 changes: 11 additions & 3 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ MainWindow::MainWindow(QWidget *parent)
this->setFixedSize(WIDTH,HEIGHT);
this->setWindowIcon(QIcon(":/svg/svg/recording_128.svg"));
//屏幕中间
this->move((QApplication::desktop()->width() -WIDTH)/2, (QApplication::desktop()->height() - HEIGHT)/2);
//this->move((QApplication::desktop()->width() -WIDTH)/2, (QApplication::desktop()->height() - HEIGHT)/2);
/*
* 显示在活动屏幕中间
*/
QScreen *screen = QGuiApplication::primaryScreen();
move((screen->geometry().width() - WIDTH) / 2,
(screen->geometry().height() - HEIGHT) / 2);


setButton=new QToolButton(this);
max_minButton=new QToolButton(this);
Expand Down Expand Up @@ -245,7 +252,7 @@ QString MainWindow::playerTotalTime(QString filePath)
file.close();
return timeStr;
}

return QString();
}
//初步配置文件例子
void MainWindow::initGsetting()
Expand Down Expand Up @@ -335,7 +342,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event){
void MainWindow::mouseReleaseEvent(QMouseEvent *event){
this->isPress = false;
this->setCursor(Qt::ArrowCursor);

QMainWindow::mouseReleaseEvent(event);
}

void MainWindow::mouseMoveEvent(QMouseEvent *event){
Expand Down Expand Up @@ -568,6 +575,7 @@ void MainWindow::setuserdirectory()
}
void MainWindow::slotOnItemDoubleClicked(QListWidgetItem *item)
{
Q_UNUSED(item);
//QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
// qDebug()<<list->currentRow();
// QWidget* getWid =list->itemWidget(item);
Expand Down