English 中文(简体)
将QGraphicsItem应用到QGraphicsItem小组造成坠毁
原标题:Appending QGraphicsItems to QGraphicsItemGroup causes crash
  • 时间:2011-11-22 11:08:52
  •  标签:
  • c++
  • qt

这是我的第一个职位。 我最近开始使用QT和C++。 令人印象深刻。 我似乎无法处理一个问题。 基本上,Im试图将许多<代码>QGraphicsItems组织成两个<代码>QGraphicsItemgroups。 这些项目使用<条码>QGraphicsScene在<条码>上显示。 制造这些物品和展示这些物品都是一种药店。 然而,当我加入这一组别时,该方案每次都坠毁了指挥部。 之所以增加这些组别,是因为后来能够选择哪些项目在油漆中生产。 相关守则列于下文。

QGraphicsScene * scene;
scene = new QGraphicsScene(this);
ui.graphicsView->setScene(scene);

QBrush whiteBrush;
QBrush imageBrush;
QPen blackPen;
whiteBrush = QBrush(Qt::white);
imageBrush = QBrush(Qt::lightGray);
blackPen = QPen(Qt::black);
blackPen.setWidth(1);

QGraphicsItemGroup * cliGroup;
QGraphicsItemGroup * alfGroup;
cliGroup = new QGraphicsItemGroup;
alfGroup = new QGraphicsItemGroup;
scene->addItem(cliGroup);
scene->addItem(alfGroup);

QGraphicsPolygonItem *poly;
poly =  scene->addPolygon(polyF, blackPen, imageBrush);
cliGroup->addToGroup(poly);        //line it crashes on

我怀疑,这在现场制造多动,然后在<条码>QGraphicsItemGroup上添加,尽管我可以说明如何改变这种说法。 我从那时起就采用了一种不太明智的解决办法,即根据类型对现场的物品进行过滤,但这只是短期和表面的。 任何建议?

最佳回答
问题回答

Rather than using new QGraphicsItemGroup, use QGraphicsScene::createItemGroup.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签