小编Ste*_*rdt的帖子

使用swig包装c ++模板模板模板类

我有一个类结构,它使用了很多我想要模板的模板.我知道有几个类似的问题上堆栈溢出周围(包装模板的模板参数类痛饮,包装与痛饮专门的C++模板类.),但他们都不工作了我的情况.

最小的示例如下所示

insane_template.h

#pragma once

class CustomAttrs{
public:
    enum dattr1d{pos,vel,someCustomCaseVar, d1dLast};
};


template <class T> 
class A
{
public:
    T attributes;
};


template <template<class> class A, class T> 
class B : public A<T>
{

};


template<template<template<class> class, class> class Op, template<class> class X, class T>
class C : public Op<X,T>
{
};

template class A<CustomAttrs>;
template class B<A, CustomAttrs>;
template class C<B, A, CustomAttrs>;
Run Code Online (Sandbox Code Playgroud)

我的insane_template.i非常简单:

%module insane

%{
#include "./insane_template.h"
%}

%include "./insane_template.h"

%template(AC) …
Run Code Online (Sandbox Code Playgroud)

c++ python swig templates

5
推荐指数
0
解决办法
236
查看次数

setItemDelegateForColunm() 在没有堆栈跟踪的情况下导致应用程序崩溃

问题:

当在 TreeView 上的每行或列设置 QtstyledItemDelegate 时,我的应用程序崩溃,没有任何进一步的信息。尽管如此,为整个 TreeView 设置 QStyledItemDelegate 的工作在我看来似乎很奇怪。

有谁知道这是否是一个已知的错误,或者我错过了什么

我正在将 PySide 1.1.2 与 Qt 4.8 一起使用(更改版本并不是真正的选择,因为这将是一个很大的开销,因为它是一个也在集群上运行的分布式应用程序,其中版本更新将包含大量开销。 .)

这是一个“最小运行示例”

from PySide import QtGui, QtCore
import sys
import easymodel

class MainWin(QtGui.QMainWindow):
    def __init__(self, model, parent=None):
        super(MainWin, self).__init__(parent)

        treeview = QtGui.QTreeView()
        treeview.setItemDelegateForColumn(0,QtGui.QStyledItemDelegate()) 
        treeview.setModel(model)
        self.setCentralWidget(treeview)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    root = easymodel.TreeItem(easymodel.ListItemData(["Test","Values","Perhabs a button"]))
    model = easymodel.TreeModel(root)    
    for i in range(1,10):
        easymodel.TreeItem(easymodel.ListItemData(["Test","Values","Perhabs a button"]),
                           parent = root,
                           index=model.index(root.child_count(),1,
                                             parent = root.index()))    


mainWin = MainWin(model)
mainWin.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)

作为模型,我使用 github 上提供的 …

python qtreeview pyside qstyleditemdelegate

4
推荐指数
1
解决办法
669
查看次数

使用逗号进行Numpy数组切片

我正在尝试学习numpy数组切片.

但这是我似乎无法理解的语法.

是什么

a [:1]做.

我在python中运行它.

a = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])
a = a.reshape(2,2,2,2)
a[:1]
Run Code Online (Sandbox Code Playgroud)

输出:

array([[[ 5,  6],
        [ 7,  8]],

       [[13, 14],
        [15, 16]]])
Run Code Online (Sandbox Code Playgroud)

有人可以向我解释切片及其工作原理.文档似乎没有回答这个问题.

另一个问题是有没有办法用类似的东西生成一个数组

np.array(1:16)或类似于python的地方

x = [x for x in range(16)]
Run Code Online (Sandbox Code Playgroud)

python arrays numpy

2
推荐指数
1
解决办法
4115
查看次数

标签 统计

python ×3

arrays ×1

c++ ×1

numpy ×1

pyside ×1

qstyleditemdelegate ×1

qtreeview ×1

swig ×1

templates ×1