Skip to content
Closed
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
13 changes: 13 additions & 0 deletions application/widgets/customcontrol/ddbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#include "ddlog.h"
#include "ddbase.h"
#include "common.h"

Check warning on line 7 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common.h" not found.

#include <QKeyEvent>

Check warning on line 9 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QShowEvent>

Check warning on line 10 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QShowEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DDBase::DDBase(QWidget *parent)
: DDialog(parent)
Expand Down Expand Up @@ -34,3 +35,15 @@
DDialog::keyPressEvent(event);
}
}

void DDBase::showEvent(QShowEvent *event)
{
if (parentWidget() && parentWidget()->screen()) {
QRect screenGeom = parentWidget()->screen()->geometry();
QRect dialogGeom = geometry();
int x = screenGeom.x() + (screenGeom.width() - dialogGeom.width()) / 2;
int y = screenGeom.y() + (screenGeom.height() - dialogGeom.height()) / 2;
move(x, y);
}
DDialog::showEvent(event);
}
6 changes: 6 additions & 0 deletions application/widgets/customcontrol/ddbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class DDBase : public DDialog
* @param event事件
*/
void keyPressEvent(QKeyEvent *event) override;

/**
* @brief 显示事件,覆盖 DTK6 默认居中逻辑
* @param event 显示事件
*/
void showEvent(QShowEvent *event) override;
};

#endif // DDBASE_H
Loading