How do I place a Checbox inside a QTextedit? I ask this because I need to create a QTextedit that has a checkbox to print
How do I place a Checbox inside a QTextedit? I ask this because I need to create a QTextedit that has a checkbox to print
It is really impossible to think of a checkbox inside a text edit field, in any UI library, in any OS. Checkboxes belong alonside text fields in dialogs, forms, etc.
Your platform seems to be Windows. I don't think you have ever seen a Windows application with a checkbox inside a text field. That ought to give something to think about.
Well you could align the checkbox inside the bounds of the edit box...
Is that I want to create a document for QPrintPreviewDialog, that has the checkbox. I want to create a document like the one that is in the Attachments.
And I try HTML:
doc.setHtml( "Soccer: <input type=\"checkbox\" name=\"sports\" value=\"soccer\" /><br />");
but doesnt work.
Last edited by afro_cv; 21st August 2011 at 02:06.
So you don't want a checkbox inside QTextEdit but rather a checkbox inside a document. You need to subclass QTextObjectInterface and implement a checkbox text object.
What is the checkbox text object? After your reply walked to investigate on google and found this examples:
http://developer.qt.nokia.com/doc/qt...extformat.html
http://doc.qt.nokia.com/latest/richtext-textobject.html
My doubt is how can I implement checkboxtextobject. In the example of nokia, they use QTextFormat:: UserObject and svgtextobject.cpp they use the drawImage method, as is the draw for the checkbox?
You need to implement a similar text object for the checkbox as they have for svg images.
I need know how to change cursor for the next 2 line , after the table to put my checkbox. Do you know how?
Qt Code:
QTextCharFormat format; QTextTableFormat fmtTable; fmtTable.setCellSpacing(0); fmtTable.setBorder(1); QFont fonte; fonte.setFamily("Calibri"); fonte.setBold(true); fonte.setPointSize(12); cursor.mergeCharFormat(format); cursor.insertText("1. Identificação\n\n"); format.setFont(fonte); table->cellAt(0, 0).firstCursorPosition().insertText("Nome : "); table->cellAt(0, 1).firstCursorPosition().insertText("Helder Lobato"); cursor.insertText("\n\n1. Identificação\n\n");To copy to clipboard, switch view to plain text mode
I want to continue writing the text after created the table, the problem is that after you create the table, I can't get out of the table cells.
Look in the atchament.
Ths in advance, Sorry for my English, I'm Portuguese and I am using bing and google to do the translation
Thanks, it was very stupid, was so tired during this morning that even noticed I was using the QTextCursor:: End without using the function movePosition.
Good Afternoon,
Wysota, would you could you explain me with an example how can I introduce a checkbox QTextDocument as you can see the attachment that I generated with QPrinter: PdfFormat. What I did to circumvent the problem of the checkbox, was to insert an image checkbox. The problem is that my teacher did not like the solution. Did you could write a mini code, or give me a link where I can draw inspiration?
DocNutrition.pdf
We are not allowed to give solutions to school assignments, so don't expect complete code from us. The SVG example should give you a good idea what you should do, just instead of drawing images, render a checkbox, either by yourself or using QStyle API.
I 'm not asking you to deliver me to the resolution of my problem, and if you repares in my posts in this forum I never asked such a thing.
I come here only for information about Qt, to understand how to work with him, and learn more about Qt to apply this in my actual ou future works.
Because sometimes you dont understand documentations and you need example ou someone to explain for you undersant.
And I asked you that, a mini-code or a link so I can understand and learn how to do what I want in Qt, because I've been looking on google,
read the documentation and Qt tutorial and I not understand how.
As I said, the example with the SVG item is all you need. I could make another example but it would probably be very similar if not worse than the SVG text item example so it doesn't make much sense, does it? At this point you just have to sit down, analyze, think and experiment.
Bookmarks