QtCreator调试助手“ hello world”

问题描述 投票:0回答:1

我正在尝试开始使用debug helpers in QtCreator

但是我什至无法获得任何简单的工作。

我制作了这个简单的python文件:

from dumper import *

def qdump_TestClass(d, value):
    d.putNumChild(0)
    d.putValue("hi")

然后在此处添加该文件:

enter image description here

这是该类的C ++定义:

struct TestClass {
    int x, y;
};

我一直在遵循this other question中的步骤。但这对我不起作用。

c++ qt-creator
1个回答
2
投票

在函数名称中使用双下划线:

def qdump__TestClass(d, value):
         ^^

并且,根据文档更正路径:

~/<Qt>/Tools/QtCreator/share/qtcreator/debugger/personaltypes.py

使用您的Qt文件夹名称(如果不在~,请使用路径。

该对话框中显示的路径是相对于app的。

这是一个完整的工作示例:

main.cpp

struct TestClass
{
    int x {12}, y {34};
};

int main()
{
    TestClass t;
    (void) t;
    return 0;
}

personaltypes.py

from dumper import *

def qdump__TestClass(d, value):
    d.putValue("TestClass")
    d.putNumChild(2)
    if d.isExpanded():
        with Children(d):
            d.putSubItem("x", value["x"])
            d.putSubItem("y", value["y"])

截屏:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.