Initial commit of BudgetPro
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
SET(VERSION_SHORT 0.1)
|
||||
project(NormalMenuBarExample VERSION ${VERSION_SHORT})
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# qt库加载,最低要求5.9
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.9 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
|
||||
# linux下会报
|
||||
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_LIST_DIR})
|
||||
add_executable(NormalMenuBarExample WIN32
|
||||
MainWindow.h
|
||||
MainWindow.cpp
|
||||
MainWindow.ui
|
||||
main.cpp
|
||||
)
|
||||
|
||||
if(NOT TARGET SARibbonBar)
|
||||
# 说明这个例子是单独加载
|
||||
message(STATUS "NOT TARGET SARibbonBar find_package(SARibbonBar REQUIRED)")
|
||||
find_package(SARibbonBar REQUIRED)
|
||||
endif()
|
||||
|
||||
target_link_libraries(NormalMenuBarExample PUBLIC SARibbonBar::SARibbonBar)
|
||||
target_link_libraries(NormalMenuBarExample PUBLIC
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
set_target_properties(NormalMenuBarExample PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
CXX_EXTENSIONS OFF
|
||||
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
|
||||
VERSION ${SARIBBON_VERSION}
|
||||
EXPORT_NAME NormalMenuBarExample
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
)
|
||||
|
||||
install(TARGETS NormalMenuBarExample
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION bin
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "MainWindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : SARibbonMainWindow(parent, false)
|
||||
{
|
||||
if (!isUseRibbon()) {
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "SARibbonMainWindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public SARibbonMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menufile">
|
||||
<property name="title">
|
||||
<string>file</string>
|
||||
</property>
|
||||
<addaction name="actionopen"/>
|
||||
<addaction name="actionsave"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuedit">
|
||||
<property name="title">
|
||||
<string>edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menufile"/>
|
||||
<addaction name="menuedit"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionopen">
|
||||
<property name="text">
|
||||
<string>open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionsave">
|
||||
<property name="text">
|
||||
<string>save</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,34 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2022-09-21T14:04:12
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
# SARibbon 1.x 版本后引入frameless库,必须要cpp17及以上
|
||||
CONFIG += c++17
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = NormalMenuBarExample
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp \
|
||||
MainWindow.cpp
|
||||
|
||||
HEADERS += \ \
|
||||
MainWindow.h
|
||||
|
||||
|
||||
|
||||
include($$PWD/../../common.pri)
|
||||
DESTDIR = $${SARIBBON_BIN_DIR}/bin
|
||||
include($${SARIBBONBAR_PRI_FILE_PATH})
|
||||
|
||||
msvc {
|
||||
QMAKE_CFLAGS += /utf-8
|
||||
QMAKE_CXXFLAGS += /utf-8
|
||||
}
|
||||
|
||||
FORMS += \
|
||||
MainWindow.ui
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include <QElapsedTimer>
|
||||
#include <QDebug>
|
||||
|
||||
//重定向qdebug的打印
|
||||
void log_out_put(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
|
||||
/**
|
||||
* @brief 重定向qdebug的打印
|
||||
* @param type
|
||||
* @param context
|
||||
* @param msg
|
||||
*/
|
||||
void log_out_put(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
fprintf(stdout, "[Debug] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
|
||||
// case QtInfoMsg:
|
||||
// fprintf(stdout, "[Info] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
|
||||
// context.function); break;
|
||||
|
||||
case QtWarningMsg:
|
||||
fprintf(stdout, "[Warning] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
|
||||
case QtCriticalMsg:
|
||||
fprintf(stdout, "[Critical] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
|
||||
case QtFatalMsg:
|
||||
fprintf(stdout, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
abort();
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stdout, "[Debug] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
break;
|
||||
}
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
qInstallMessageHandler(log_out_put);
|
||||
QFont f = a.font();
|
||||
|
||||
f.setFamily("微软雅黑");
|
||||
a.setFont(f);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return (a.exec());
|
||||
}
|
||||
Reference in New Issue
Block a user