编程杂记(一些容易忘记的笔记)

1、#pragma warning(disable:4996) :老版本警告去除

2、库导入、导出

#ifdef _WIN32
#ifdef _WINDLL
#define HSDEVICE_API _declspec(dllexport)	///< 动态库导出
#else
#define HSDEVICE_API _declspec(dllimport)	///< 动态库导入
#endif
#else
#define HSDEVICE_API 	///< 动态库导出
#endif

3、#pragma execution_character_set(“utf-8”) :解决中文乱码
4、dumpbin /dependents 查看库连接
5、解决qt的this application failed to start because is could not find or load the Qt platform plugin “windows” :main里面加QApplication::addLibraryPath("./plugins");并把qt安装环境的plugins\platforms拷贝的执行文件目录内

6、qt cmake demo:

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

# 搜索当前目录下的源文件
aux_source_directory(. DIR_SRCS)
find_package(Qt5Widgets)
find_package(Qt5Gui)
find_package(Qt5Core)
find_package(Qt5Multimedia)

include_directories(
	./
	./preview/include
	./ffmpeg/include
)
link_directories(
	./preview/lib
	./ffmpeg/lib
)

# 添加ui文件
qt5_wrap_ui(ui_FILES ./mainwindow.ui)
qt5_add_resources(res_FILES ./pic.qrc ./qcss.qrc)

add_executable(VideoMonitoringSystem ${DIR_SRCS} ${ui_FILES} ${res_FILES})

target_link_libraries(VideoMonitoringSystem Qt5::Widgets Qt5::Gui Qt5::Core Qt5::Multimedia)

# 连接第三方库
target_link_libraries(
	VideoMonitoringSystem
	HsDeviced
	HsDeviceLogind
	HsDevicePreviewd
	libcurld
	avcodec
	avformat
	avutil
	swscale
	HsDeviceACodecd
)

7、数据库连接失败"Access denied for user ‘root’@‘120.85.126.36’ (using password: YES) QMYSQL: Unable to connect"的解决方法:
GRANT ALL PRIVILEGES ON . TO ‘root’@‘120.85.126.36’ IDENTIFIED BY ‘macrovideo’ WITH GRANT OPTION;

8、类内把自身成员函数作为回调函数忽略成员函数的this参数:std::bind(&Preview::CallBack,this,std::placeholders::_1)
9、git笔记:
(1)git config --system --unset credential.helper 重新输入账号密码
(2)ssh-keygen -t rsa -C “[email protected]” 生成密钥
10、cmake笔记:
系统变量:PROJECT_BINARY_DIR=全路径/build
PROJECT_SOURCE_DIR=全路径/src

QT:
1.QSharedPointer m_devAddView; 配合m_devAddView.reset(new AddDevView); 当前界面需要重复创建,且不能指定父窗口的情况下使用;会自动释放内存;
1.qRegisterMetaType<:FrameData>(“FrameData”);
qRegisterMetaType(“FrameData&”); 使用信号、槽传递自定义类型时,得先注册类型

你可能感兴趣的:(笔记)