How to create a valid and "usable" QTextFrameFormat
-
One difference:
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
where your code just declare a new one.
QTextFrameFormat format1;So I wonder if its need more "setup"
-
@mrjj
One thing that differs is that i declare all my variables in the stack, while the example declares them in the heap, but i hope that all that works in the heap should work also in the stack and vice-versa...My intention was to make a QTextDocument, put in this a QTextFrame, put a text in it with a QTextCursor, create a QTextFrameFormat to be applied to the QTextFrame...
-
minimal sample that works for me
QTextEdit *editor = new QTextEdit;
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextFrame *topFrame = cursor.currentFrame();
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
topFrameFormat.setPadding(16);
topFrame->setFrameFormat(topFrameFormat);
cursor.insertBlock();
cursor.insertText("321 City Street"); -
@Nixxer
Well it crashes before you run out of scope so I doubt it is related to the stack :) -
@Nixxer said:
One thing I wondered:
The sample does not new / create a QTextDocument as far as I can see.
I wonder if it is needed to do , or I simply don't understand what you want to do :) -
@mrjj
I'll try this snippet, maybe I'll learn something...I begin with the QTextDocument because I'd like to make a program to make documents, like a list of properties of a client, so I thought that I could make a QTextDocument in which inserting one after one these properties with different frames and their ...
Maybe I took the problem by the wrong way...
Btw, I was thinking to make this program as a exercise to begin to "mess" with Qt...
-
Hi,
In that case, I'd recommend the excellent "C++ GUI Programming with Qt 4 (2nd Edition)" from Mark Summerfield and Jasmin Blanchette. Although it's Qt 4, it still relevant for Qt 5 and there's a good chapter about QTextDocument
-
@Nixxer
Like a database with clients and their properties ?
Depending on your coding skills, construction a RTF doc on the fly is maybe a somewhat hardcore start :) -
@SGaist
Thanks for the suggestion! If I can learn something for Qt 5, I'll gladly read this book... -
@mrjj
It's right, but I prefer to learn starting from "real" problems (I'm an self-taught "programmer")... -
@Nixxer
Well thats really understandable. More fun when it's real.
I can only second SGaist book suggestion.
I found it free on
http://www.bogotobogo.com/cplusplus/files/c-gui-programming-with-qt-4-2ndedition.pdf
(takes a moment to load)Good luck