草庐IT

item_property

全部标签

c++ - 有效 C++ : Item 52 and how to avoid hiding all normal operator new & delete versions

在Myer的EffectiveC++的第52项(自定义新的和删除的)的末尾,他讨论了如何在实现自定义版本时避免隐藏正常的新的和删除的版本,如下所示:Ifyoudeclareanyoperatornewsinaclass,you'llhideallthesestandardforms.Unlessyoumeantopreventclassclientsfromusingtheseforms,besuretomakethemavailableinadditiontoanycustomoperatornewformsyoucreate.Foreachoperatornewyoumakeava

c++ - 如何在 boost 图形库中使用 `randomize_property` 和捆绑属性图?

在文档中:http://www.boost.org/doc/libs/1_46_1/libs/graph/doc/random.html#randomize_property只有一个函数原型(prototype),我找不到一个有效的例子。我尝试了几件事,但就是无法编译。这是一个简单的源代码:#include#include#include#include#include#include#includeusingnamespacestd;usingnamespaceboost;structEdgeProperty{intcost;};typedefadjacency_listGraph;

c++ - boost 图形库 : Bundled Properties and iterating across edges

只是想了解一下BoostGraphLibrary,我有几个问题。我正在编写一些代码,它是BGL图的包装类。我的想法是,我可以随心所欲地操作图表,然后调用包装方法以GEXF(XML)格式输出图表。我的代码是这样的:structVertex{std::stringlabel;...};structEdge{std::stringlabel;doubleweight;...};typedefboost::adjacency_listGraphType;templateclassGEXF{private:Graphgraph;...};templatevoidGEXF::buildXML(){

c++ - boost::property_tree 无一异常(exception)

我需要解析一些INI文件。为此,我尝试使用boost::property_tree,但在我的系统中不允许出现异常。如何在使用boost::property_tree时禁用异常支持?如果没有办法做到这一点,非常感谢对其他图书馆的任何建议。在@sehe的回答后,我尝试了这段代码,但是没有成功:#include#include#include#includenamespaceboost{voidthrow_exception(std::exceptionconst&e){std::cerr编译行代码使用以下参数:-c-DBOOST_USER_CONFIG=""-DBOOST_NO_EXCEP

c++ - 与 boost::property_tree XML 解析器一起使用时 boost::coroutine 库崩溃

我正在使用Simple-Web-Server用于创建将XML转换为JSON的简单Web服务的库,反之亦然。反过来,它使用了几个boost库以及其中的boost::coroutine。对于XMLJSON转换,我使用boost::property_tree库进行中间表示。这是代码:#include#include#include#defineBOOST_SPIRIT_THREADSAFE#include#include#includeusingnamespacestd;usingnamespaceboost::property_tree;usingHttpServer=SimpleWeb:

iphone - (iphone) 可以为 C++ 类/结构定义 @property 吗?

我正在混合使用c++和objectc。特别是,我在object-cheader中添加了一个c++类/结构变量,这是否合法?例如,@interfaceMyView:UIView{MyCppClasscppVariable;}@property(nonatomic,assign)MyCppClasscppVariable;@end在实现文件中,@synthesizecppVariable; 最佳答案 如thisofficialdocumentonObjective-C++中所述,您可以在Objective-C类中包含非指针C++对象。如

c++ - Objective C "@property (nonatomic, retain)"的 C++ 等价物是什么?

我想知道如何在C++中正确创建属性。在ObjectiveC中,我使用“@property”(通常与(nonatomic,retain)属性一起使用)。C++中正确的方法是什么?谢谢!! 最佳答案 正如Seva所说,C++中没有那种意义上的属性。你可以做什么:用boost::share_ptr写一个类成员变量,并可选择为该成员编写getter和setter。但这甚至不是真正必要的,尽管可能被认为是良好的行为。typedefboost::shared_ptrStringPtrT;classA{public:voidsetStringPr

c++ - 如何在qlistWidget中模拟双击item

如何在没有子类的情况下模拟双击QListWidget中的项目?当我向列表中添加新项目时,我希望该项目立即进入编辑模式。 最佳答案 voidQListWidget::editItem(QListWidgetItem*item)不是正确的方法吗? 关于c++-如何在qlistWidget中模拟双击item,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/12741943/

c++ - 为什么我收到错误 : initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?

我是C++的新手,在盯着它看了太久之后终于放弃了尝试编译它。编译器似乎出于某种原因拒绝了头文件中的构造函数原型(prototype)......我无法弄清楚它有什么问题。项目.h:#ifndefITEM_H_#defineITEM_H_classItem{public:Item(int);//ThislineiswhatEclipsekeepsflaggingupwiththeerrorinthetitlevirtual~Item();Item*getNextPtr();intgetValue();voidsetNextPtr(Item*);};#endif/*ITEM_H_*/在我的

c++ - 如何使用 Item Delegate 检测 QListView <-> QAbstractListModel 中的行选择?

我选择的QListView->QAbstractListModel似乎对内置选择支持为零。我必须从头开始编写所有内容吗?在UI中捕获选择事件,将模型项标记为已选中等?似乎没有开箱即用的支持。奇怪的是有一个QItemSelectionModel确实支持这个,但是你不能将它与QListView一起使用,因为它不是从QAbstract派生的......我的模型类是否应该使用多重继承来继承QItemSelectionModel和QAbstractListModel?否则我不知道如何才能避免自己重写这个功能。我的最终目标是让绘制我的项目的代理知道项目是否被选中,包括在paint和sizeHint