Results 1 to 17 of 17

Thread: CheckBox inside a TextEdit

  1. #1
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default CheckBox inside a TextEdit

    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

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: CheckBox inside a TextEdit

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    Quote Originally Posted by afro_cv View Post
    How do I place a Checbox inside a QTextedit?
    The same way you place any widget inside any other widget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    Well you could align the checkbox inside the bounds of the edit box...

  5. #5
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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.
    Attached Files Attached Files
    Last edited by afro_cv; 21st August 2011 at 02:06.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    You need to implement a similar text object for the checkbox as they have for svg images.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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:
    1. QTextDocument *document = ui->textEdit->document();
    2. QTextCursor cursor(document);
    3.  
    4. cursor.movePosition(QTextCursor::Start);
    5. cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
    6.  
    7. QTextTableFormat fmtTable;
    8. fmtTable.setCellSpacing(0);
    9. fmtTable.setBorder(1);
    10. format.setFontWeight(QFont::Bold);
    11. QFont fonte;
    12. fonte.setFamily("Calibri");
    13. fonte.setBold(true);
    14. fonte.setPointSize(12);
    15. cursor.mergeCharFormat(format);
    16. cursor.insertText("1. Identificação\n\n");
    17. format.setFont(fonte);
    18.  
    19. QTextTable *table =cursor.insertTable(1,2,fmtTable);
    20. table->cellAt(0, 0).firstCursorPosition().insertText("Nome : ");
    21. table->cellAt(0, 1).firstCursorPosition().insertText("Helder Lobato");
    22.  
    23. cursor.insertText("\n\n1. Identificação\n\n");
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    I don't know what you mean by "change cursor".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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
    Attached Files Attached Files

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    QTextCursor has all the facilities needed to reposition the cursor.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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.

  14. #14
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #16
    Join Date
    Aug 2011
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CheckBox inside a TextEdit

    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.

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: CheckBox inside a TextEdit

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. problem with keypressevent inside textedit
    By serula in forum Newbie
    Replies: 4
    Last Post: 28th April 2011, 13:03
  2. Inserting label inside textEdit widget
    By dshan in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2011, 11:17
  3. insert hyperlink(URL) inside the TextEdit..
    By rleojoseph in forum Qt Programming
    Replies: 10
    Last Post: 6th January 2011, 07:15
  4. CheckBox inside a QTableView
    By voilier92 in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2010, 05:04
  5. Replies: 2
    Last Post: 5th June 2008, 21:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.