40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
#include "./Widget/MainWidget.h"
|
||
#include <QApplication>
|
||
#include <QItemSelection>
|
||
#include <QItemSelectionModel>
|
||
#include <windows.h>
|
||
#include <iostream>
|
||
#include <QDebug>
|
||
|
||
//通过设置项目的子系统来避免生成控制台窗口。这种方法根本不会创建控制台窗口:
|
||
//
|
||
//右键点击你的项目,选择“属性”。
|
||
//在“配置属性”下,展开“链接器”,然后选择“系统”。
|
||
//将“子系统”设置为“Windows(/ SUBSYSTEM)”而不是“控制台(/ SUBSYSTEM)”。
|
||
//这种方法不需要任何额外的代码,且最为简洁。如果你已经在代码中使用了WinMain而不是main函数,这个设置就是默认的。
|
||
//
|
||
|
||
// 关闭控制台窗口的函数
|
||
void closeConsole() {
|
||
HWND hwnd = GetConsoleWindow();
|
||
ShowWindow(hwnd, SW_HIDE);
|
||
}
|
||
|
||
int main(int argc, char* argv[]) {
|
||
//closeConsole(); // 调用函数关闭控制台窗口
|
||
//FreeConsole(); // 关闭控制台窗口
|
||
QApplication app(argc, argv);
|
||
|
||
// **注册 QItemSelection 和 SelectionFlags 以支持 QueuedConnection**
|
||
qRegisterMetaType<QItemSelection>("QItemSelection");
|
||
qRegisterMetaType<QItemSelectionModel::SelectionFlags>("QItemSelectionModel::SelectionFlags");
|
||
|
||
qDebug() << "Current working directory:" << QDir::currentPath();
|
||
//QIcon appIcon("./app_icon.ico");
|
||
//app.setWindowIcon(appIcon);
|
||
|
||
MainWidget w;
|
||
w.show();
|
||
return app.exec();
|
||
}
|