Skip to content

Commit

Permalink
强制更新mdimainwidow例子的命名,让git更新
Browse files Browse the repository at this point in the history
  • Loading branch information
czyt1988 committed Sep 12, 2024
1 parent d4183e7 commit 633c496
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 70 deletions.
Binary file added doc/pic/赞赏码.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/example/MdiAreaWindowExample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.8 COMPONENTS Core Gui Widgets REQUIRED)

add_executable(${SARIBBON_EXPAMPLE_NAME} WIN32
mainWindow.h
mainWindow.cpp
mdimainWindow.h
mdimainWindow.cpp
MainWindow.ui
main.cpp
icon.qrc
Expand Down
68 changes: 34 additions & 34 deletions src/example/MdiAreaWindowExample/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "mainwindow.h"
#include "mdimainwindow.h"
#include <QApplication>
#include <QDebug>
#include <QElapsedTimer>
Expand All @@ -14,51 +14,51 @@ void log_out_put(QtMsgType type, const QMessageLogContext& context, const QStrin
*/
void log_out_put(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QByteArray localMsg = msg.toLocal8Bit();

switch (type) {
case QtDebugMsg:
fprintf(stdout, "%s |[Debug] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;
switch (type) {
case QtDebugMsg:
fprintf(stdout, "%s |[Debug] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;

case QtWarningMsg:
fprintf(stdout, "%s |[Warning] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;
case QtWarningMsg:
fprintf(stdout, "%s |[Warning] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;

case QtCriticalMsg:
fprintf(stdout, "%s |[Critical] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;
case QtCriticalMsg:
fprintf(stdout, "%s |[Critical] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;

case QtFatalMsg:
fprintf(stdout, "%s |[Fatal] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
abort();
break;
case QtFatalMsg:
fprintf(stdout, "%s |[Fatal] (%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
abort();
break;

default:
fprintf(stdout, "%s |[Debug](%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;
}
default:
fprintf(stdout, "%s |[Debug](%s[%u],%s)\n", localMsg.constData(), context.function, context.line, context.file);
break;
}
#ifndef QT_NO_DEBUG_OUTPUT
fflush(stdout);
fflush(stdout);
#endif
}

int main(int argc, char* argv[])
{
// 以下是针对高分屏的设置,有高分屏需求都需要按照下面进行设置
SARibbonBar::initHighDpi();
// 以下是针对高分屏的设置,有高分屏需求都需要按照下面进行设置
SARibbonBar::initHighDpi();

QApplication a(argc, argv);
qInstallMessageHandler(log_out_put);
QFont f = a.font();
f.setFamily(u8"微软雅黑");
a.setFont(f);
QElapsedTimer cost;
QApplication a(argc, argv);
qInstallMessageHandler(log_out_put);
QFont f = a.font();
f.setFamily(u8"微软雅黑");
a.setFont(f);
QElapsedTimer cost;

cost.start();
MainWindow w;
qDebug() << "window build cost:" << cost.elapsed() << " ms";
w.show();
cost.start();
MainWindow w;
qDebug() << "window build cost:" << cost.elapsed() << " ms";
w.show();

return (a.exec());
return (a.exec());
}
34 changes: 0 additions & 34 deletions src/example/MdiAreaWindowExample/mainwindow.cpp

This file was deleted.

34 changes: 34 additions & 0 deletions src/example/MdiAreaWindowExample/mdimainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "mdimainwindow.h"
#include "ui_MainWindow.h"
#include <QTextEdit>
#include <QMdiSubWindow>
#include "SARibbonBar.h"
#include "SARibbonCategory.h"
#include "SARibbonPannel.h"
MainWindow::MainWindow(QWidget* parent) : SARibbonMainWindow(parent), ui(new Ui::MainWindow)
{
// 注意,你必须在ui文件中删除菜单栏,否则会拿到空的ribbon指针
ui->setupUi(this);
SARibbonBar* ribbon = ribbonBar();
SARibbonCategory* mainPage = new SARibbonCategory("Main");
ribbon->addCategoryPage(mainPage);
buildMainPage(mainPage);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::buildMainPage(SARibbonCategory* mainPage)
{
SARibbonPannel* mainPannel = new SARibbonPannel("operate");
mainPannel->addAction(ui->actionadd_window);
mainPage->addPannel(mainPannel);
}

void MainWindow::on_actionadd_window_triggered()
{
QMdiSubWindow* sub = ui->mdiArea->addSubWindow(new QTextEdit());
sub->show();
}

0 comments on commit 633c496

Please sign in to comment.