在Qt Designer中添加派生类
我介绍的是基类为QMainWindow的窗体,想要在MainWindow::centralwidget下添加一个派生类,但又不想采用工具栏中添加原有的类型,如Frame、Widget等,比如要添加class SceneView,可以采用以下方式,先拖一个widget窗体到窗口中,图1,
然后右击widget——promote to…….弹出一个窗口,图2,

在Promoted class name中写入**,点击Add,图3,


我介绍的是基类为QMainWindow的窗体,想要在MainWindow::centralwidget下添加一个派生类,但又不想采用工具栏中添加原有的类型,如Frame、Widget等,比如要添加class SceneView,可以采用以下方式,先拖一个widget窗体到窗口中,图1,
然后右击widget——promote to…….弹出一个窗口,图2,

在Promoted class name中写入**,点击Add,图3,


1、轻量级3D显示C++库( Qt + OpenGL )
https://gillesdebunne.github.io/libQGLViewer/index.html
libQGLViewer 是一个基于 Qt 的 C++ 库,可简化 OpenGL 3D 查看器的创建。它提供了一些典型的 3D 查看器功能,例如使用鼠标移动相机的功能,而大多数其他 API 都缺乏此功能。其他功能包括鼠标操作帧、插值关键帧、对象选择、立体显示、屏幕截图保存等等。它既适合 OpenGL 初学者,也可用于创建复杂的应用程序,并且完全可定制且易于扩展。它基于 Qt 工具包,可在任意架构(Unix-Linux、Mac、Windows)上编译。它提供了完整的参考文档和大量示例。libQGLViewer 无法以各种格式显示 3D 场景,但它可以作为此类查看器编码的基础。
#include <filesystem>
static void Get_All_PCD_File(const std::string &pcd_dir, std::vector<std::string> &file_paths)
{
file_paths.clear();
if(std::filesystem::exists(pcd_dir) && std::filesystem::is_directory(pcd_dir)){
try{
for(const auto& entry : std::filesystem::directory_iterator(pcd_dir)){
if(std::filesystem::is_regular_file(entry.path())){
if(entry.path().extension() !=".pcd" && entry.path().extension() !=".PCD"){
continue;
}
file_paths.push_back(entry.path().string());
}
}
}catch(const std::filesystem::filesystem_error& e) {
std::cerr << "Filesystem error: " << e.what() << std::endl;
return;
}
}else{
printf("Err: path is not exist!\n");
return;
}
return;
}
C 库函数 double modf(double x, double *integer) 返回值为小数部分(小数点后的部分),并设置 integer 为整数部分。
modf() 是 C 标准库 <math.h> 中的一个函数,用于将一个浮点数分解为整数部分和小数部分。它通常用于需要将浮点数分离成整数和小数部分的场景。
下面是 modf() 函数的声明。
#include <math.h>double modf(double x, double *iptr);float modff(float x, float *iptr);long double modfl(long double x, long double *iptr);
该函数返回 x 的小数部分,符号与 x 相同。
下面的实例演示了 modf() 函数的用法。
让我们编译并运行上面的程序,这将产生以下结果:
整数部分 = 8.000000
小数部分 = 0.123456