QtPropertyBrowser的源码位置目录如下,在Src的qttools的shared目录下
如果没有安装源码,也可以在github上下载,地址如下:
qt4版本:https://github.com/qtproject/qt-solutions/tree/master/qtpropertybrowser
qt5版本:https://github.com/qt/qttools/tree/dev/src/shared/qtpropertybrowser
使用
- 在QtCreator中,新建个Qt项目并在.pro文件中加入这句即可引用QtPropertyBrowser
include($$[QT_INSTALL_PREFIX]/…/Src/qttools/src/shared/qtpropertybrowser/qtpropertybrowser.pri)
// 把其当做一个普通QWidget插入布局即可显示
auto property = new QtTreePropertyBrowser(this);
main_layout->addWidget(property);
效果如下图所示,但是因为没有设置内容,所以控件里面是空的。
. Right click and select Properties.
In the property page go to Configuration Properties -> Qt Meta-Object-Compiler -> moc
and set Dynamic C++ Source to Disable. This will exclude generated moc_ files from direct compilation. They will be compiled as an include in the cpp files from qtpropertybrowser, the way they were meant to be.
解决方法
:将除了qtpropertybrowserutils_p.h之外的头文件全部选中并右击,在配置属性中更改moc
的Dynamic C++ Source
为Disable
即可
参考:
https://blog.youkuaiyun.com/qq_37996632/article/details/115337891