Hi,

hm that confuses me a bit. How does Qt manage this?

Let's take the example above. I have a QTextEdit that internaly has a QTextCursor member (non-pointer).

In my function, I create a new QTextCursor object that should be a copy of the QTextEdit's QTextCursor:
Qt Code:
  1. QTextCursor cursorCopy = edit->textCursor();
To copy to clipboard, switch view to plain text mode 
Question 1: How does Qt manage this now? How can Qt have a connection between this copy and the internal QTextCursor of QTextEdit if it is just a copy, not a pointer??

Question 2: If you were right and there exists any mystic connection between the copy and the original QTextCursor, then the following should work, too:
Qt Code:
  1. edit->textCursor().setPosition(int);
To copy to clipboard, switch view to plain text mode 
But it doesn't work. I can only set a new cursor position by changing the cursor position in the copy and replacing the original QTextCursor with the copy by:
Qt Code:
  1. edit->setTextCursor(QTextCursor);
To copy to clipboard, switch view to plain text mode 
Well, for me it seems to be logical that it doesn't work, because:
Qt Code:
  1. edit->textCursor();
To copy to clipboard, switch view to plain text mode 
only gives me a copy, so changing cursor postion via:
Qt Code:
  1. edit->textCursor().setPosition(int);
To copy to clipboard, switch view to plain text mode 
will never apply to QTextEdit but only to the copy.

So after all, I'm still wondering about this behaviour. Why does it have some features like a pointer with a real connection to QTextEdit's textcursor when the code above fails (like it is expected for a non-pointer copy) ??

Sorry but I really want to understand that...