[Qt-interest] QGraphicsScene and mouse events
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Fri Nov 26 16:20:37 CET 2010
On 2010-11-26 Mahendra Mahendra G.R wrote:
> Hi Oliver,
>
> I just gave the full code so that someone can run and see what the problem is
> because i didnt know how to explain it, yea i checked the diagram scene example
> but its not very clear to me. Regarding my problem, i want to know if its possible
> to delete all the items and just keep one item which was added in the end!, i looked
> in for clear() method and items() method, but not sure how to do it.
That is the second most important rule of mailing lists: DON'T write people in private, unless the message is really meant to be private - yours is clearly not!
Again, my point is the same: if you don't know how to explain the problem, how do you expect ANYONE to understand what you mean?
So to your question: yes, sure it is possible to delete all but the last one added. Just keep track of the item which was added last somehow, e.g. in a member variable
QGraphicsItem *m_lastAddedItem;
Then delete all items but this one. Or keep a list of all items, and append new items to the end. Then delete the first n - 1 items. There are probably dozens of other approaches, but this is *basic* software engineering.
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list