Results 1 to 4 of 4

Thread: Draw vertical Line in QTextEdit

  1. #1
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question Draw vertical Line in QTextEdit

    Hi there,

    I am in the process of writing a custom Code /Script Editor. An i thought i would be nice to have a "vertical - line" drwan along the right side of the "Text" as a page delimiter.

    I have tried to find something on this but i guess im not using the right Keywords.

    I found something while goting through the list of possible things provided by the syntaxcompleter:

    QTextEdit::VLine
    QTextEdit::HLine

    But i have no clue waht i can do with these... (and even if they are what im thinking about) I havent been able to find them in the documentation... so I ask here

    If anyone can give me a tip on how to acomplish this, id be grateful.
    Last edited by ericV; 22nd July 2009 at 15:04.

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

    Default Re: Draw vertical Line in QTextEdit

    I don't think you'd want to use these... You probably have to draw a regular line using QPainter in appropriate place of the viewport.
    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.


  3. #3
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Draw vertical Line in QTextEdit

    Thanks for the sudgestion.... i will try it with the QPainter

    Edit:
    Cant seem to get it to work.... it compiles but there is no line ...
    i wrote this in my constructor for the editor:

    Qt Code:
    1. QPainter linePainter(editor);
    2.  
    3. int y1 = editor->rect().topLeft().y();
    4. int y2 = editor->rect().bottomLeft().y();
    5. int x = editor->rect().topLeft().x();
    6. x += QFontMetrics(f).width("x")*70;
    7.  
    8. QLine vLine = QLine(x,y1,x,y2) ;
    9.  
    10. linePainter.drawLine(vLine);
    To copy to clipboard, switch view to plain text mode 
    Last edited by ericV; 22nd July 2009 at 15:36.

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

    Default Re: Draw vertical Line in QTextEdit

    It doesn't work like that. You have to paint the line from within the paint event each time your widget is redrawn.
    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. How to draw vertical text via QTextEdit
    By nifei in forum Qt Programming
    Replies: 8
    Last Post: 1st October 2010, 17:10
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.