从QtreeWidget(Qt)获取标题名称

最后编辑了

如何获得QtreeWidget’s column names

Here is an example you can run using the itemviews example. The QTreeWidget is in the lower rightmost section. To adapt this script for your own application, use the “picker”EyeDropper找出物体’s symbolic name in your application and replace the name with it in your own script.

function main()
{
    startApplication("itemviews");

    // hardcoded object name
    var name = {"aboveWidget": names.Item_Views_qt_splithandle_QSplitterHandle, "type": "QTreeWidget",
    "unnamed": "1", "visible": "1", "window": names.ItemViews_MainWindow};
    var treeWidget = waitForObject(name);
    var header = treeWidget.headerItem();
    test.log("total columns: " + header.columnCount());
    for (i = 0; i < header.columnCount(); i++) {
        test.log("column #" + i + ": " + header.text(i));
    }
}