Results 1 to 11 of 11

Thread: QTextEdit column select ?

  1. #1
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QTextEdit column select ?

    Hi,

    Does the Q(Plain)TextEdit widget supports column selection ?
    I have heard it was the case in Qt3, but I saw nothing about it in Qt4.

    If not, any idea about how to implement such a thing ?

    thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit column select ?

    Neither QPlainTextEdit nor QTextEdit support column selection and I doubt that such a feature is on the TODO list of the Trolls (Noks now...).

    Implementing this for QTextEdit/QTextDocument (or the plain text counterpart) will probably be hackish and quite painful (if doable at all). The only Qt-based editor that I know of which features column selection is QCodeEdit.
    Current Qt projects : QCodeEdit, RotiDeCode

  3. The following user says thank you to fullmetalcoder for this useful post:

    kib2 (25th October 2008)

  4. #3
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit column select ?

    Thanks fullmetalcoder,

    Quote Originally Posted by fullmetalcoder View Post
    Neither QPlainTextEdit nor QTextEdit support column selection and I doubt that such a feature is on the TODO list of the Trolls (Noks now...).
    Does that mean that we always have to stay with the awfull Scintilla control to write a descent editor (it's a good control, but you have to write your own parser for any new langage : a pain ).

    Quote Originally Posted by fullmetalcoder View Post
    Implementing this for QTextEdit/QTextDocument (or the plain text counterpart) will probably be hackish and quite painful (if doable at all). The only Qt-based editor that I know of which features column selection is QCodeEdit.
    I've tried it, but got errors when compiling.

    How did you implemented the folding ? (I'm' just curious, I found nothing about this).
    Do you project to make a QtPlugin for it ?

  5. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit column select ?

    I've tried it, but got errors when compiling.
    Please send me more informations about this (version used, compiler, platform, Qt version, compile log...) so that I may be able to fix things (if they are still broken in the latest version).

    it's a good control, but you have to write your own parser for any new langage : a pain
    IMO QScintilla sucks for two main reasons :

    • it lacks flexibility
    • its API is really crappy

    In QCodeEdit I tried to address both issues :

    • By adding a syntax engine that fetches languages definitions from XML files, thus relieving developers of the complicated parser writing phase
    • By adding the concept of panels which allow complete customization of the editor (line number, line marks, folding indicators, ... are all done in separate panels which can be easily enabled/disabled)
    • QCodeEdit API has been designed to be close to QTextEdit API


    How did you implemented the folding ? (I'm' just curious, I found nothing about this).
    In QCodeEdit I implemented folding in the most straightforward way : giving a HIDDEN flag to the lines (or blocks to speak in QTextDocument). This is possible because I reimplmented my document and editor classes from scratch.

    In a previous version that still used QTextEdit as a base class I hacked a crappy code folding by deleting the text to hide but keeping it in a custom QTextBlockUserData object attached to the first line of the folded block. This worked but messed up the undo stack so it was not a viable solution.

    Do you project to make a QtPlugin for it ?
    Do you mean Qt Designer plugin? It was not on my TODO list but I may consider doing it if some people show interest for such a feature.
    Current Qt projects : QCodeEdit, RotiDeCode

  6. #5
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit column select ?

    Quote Originally Posted by fullmetalcoder View Post
    Please send me more informations about this (version used, compiler, platform, Qt version, compile log...) so that I may be able to fix things (if they are still broken in the latest version).
    Ok, I'll retry tomorrow and send you a report.

    Quote Originally Posted by fullmetalcoder View Post
    IMO QScintilla sucks for two main reasons :

    • it lacks flexibility
    • its API is really crappy
    Yes, and it's really annoying ; everyone is using it because it's the only one that provides a rather "good" syntax highlighting (good does not means configurable here, rather functionnal), code folding, and column selection too for free. But once you get it, you're stuck with the given lexers, and writting your own is just a pain.

    Quote Originally Posted by fullmetalcoder View Post
    In QCodeEdit I tried to address both issues :

    • By adding a syntax engine that fetches languages definitions from XML files, thus relieving developers of the complicated parser writing phase
    • By adding the concept of panels which allow complete customization of the editor (line number, line marks, folding indicators, ... are all done in separate panels which can be easily enabled/disabled)
    • QCodeEdit API has been designed to be close to QTextEdit API
    I really think it's the way to go for any descent editor.

    Quote Originally Posted by fullmetalcoder View Post
    In QCodeEdit I implemented folding in the most straightforward way : giving a HIDDEN flag to the lines (or blocks to speak in QTextDocument). This is possible because I reimplmented my document and editor classes from scratch.
    Yes, I've already think of this : text is a list of lines, and when you fold it, you just
    hide some parts of the list contents, but what are the penalties (in speed ) ?

    Quote Originally Posted by fullmetalcoder View Post
    In a previous version that still used QTextEdit as a base class I hacked a crappy code folding by deleting the text to hide but keeping it in a custom QTextBlockUserData object attached to the first line of the folded block. This worked but messed up the undo stack so it was not a viable solution.
    I've never used QTextBlockUserData before; when looking at it quickly, it seems good for matching pairs of parenthesis, etc. If I can use it for folding too, it may be a good idea.
    I suppose you've also made controls for margins too : folding and line numbers (I've made the last one, but it became slow on large files).

    Quote Originally Posted by fullmetalcoder View Post
    Do you mean Qt Designer plugin? It was not on my TODO list but I may consider doing it if some people show interest for such a feature.
    That's what I meant In fact, I'm not programming in C++, I use Python, but if I can use your control with some of the things I've made with my older one (sort of "multi cursors" [you can drag them everywhere, then type something : all the cursors are updated once you enter some text], snippets, etc), I'll be near heaven

  7. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit column select ?

    Quote Originally Posted by kib2 View Post
    Yes, I've already think of this : text is a list of lines, and when you fold it, you just
    hide some parts of the list contents, but what are the penalties (in speed ) ?
    The speed is really a matter of implementation. In QCodeEdit I got incredible speed (you can fold tens of thousands of lines in a matter of milliseconds) by storing a map of hidden regions (start line and size) which allows fast coordinate transforms (visual line <=> actual text line) and get rid of the need to iterate over the whole document to draw line numbers (or line marks and similar things... however folding indicator still require complete iteration right now).

    Quote Originally Posted by kib2 View Post
    I've never used QTextBlockUserData before; when looking at it quickly, it seems good for matching pairs of parenthesis, etc. If I can use it for folding too, it may be a good idea.
    Not such a good solution actually (unless you're tied to QTextEdit) for the reasons I've explained above. If you're interested in implementing code folding this way you may be interested in having a look at old Edyuk versions (up until 0.9.x)

    Quote Originally Posted by kib2 View Post
    That's what I meant In fact, I'm not programming in C++, I use Python, but if I can use your control with some of the things I've made with my older one (sort of "multi cursors" [you can drag them everywhere, then type something : all the cursors are updated once you enter some text], snippets, etc), I'll be near heaven
    Are you sure a designer plugin is enough to use a component within Python? I'd have thought it would be necessary to wrap the whole lib just like QScintilla does...
    Current Qt projects : QCodeEdit, RotiDeCode

  8. #7
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit column select ?

    Quote Originally Posted by fullmetalcoder View Post
    The speed is really a matter of implementation. In QCodeEdit I got incredible speed (you can fold tens of thousands of lines in a matter of milliseconds) by storing a map of hidden regions (start line and size) which allows fast coordinate transforms (visual line <=> actual text line) and get rid of the need to iterate over the whole document to draw line numbers (or line marks and similar things... however folding indicator still require complete iteration right now).
    That seems impressive.


    Quote Originally Posted by fullmetalcoder View Post
    Not such a good solution actually (unless you're tied to QTextEdit) for the reasons I've explained above. If you're interested in implementing code folding this way you may be interested in having a look at old Edyuk versions (up until 0.9.x).
    Ok, thanks I'll take a closer look at it.

    Quote Originally Posted by fullmetalcoder View Post
    Are you sure a designer plugin is enough to use a component within Python? I'd have thought it would be necessary to wrap the whole lib just like QScintilla does...
    No, not at all. I think we must wrap it using SIP, like QScintila does.


    Here's my report on trying to build QCodeEdit 2.1:
    http://share11.appspot.com/3421

  9. #8
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit column select ?

    Quote Originally Posted by kib2 View Post
    That seems impressive.
    It did require some work but line wrapping is even more of a challenge (almost done in SVN)

    Quote Originally Posted by kib2 View Post
    Ok, thanks I'll take a closer look at it.
    Just remember that this solution is FAR from ideal (even QScintilla ought to be prefered unless you have pretty good reasons to stick to QTextEdit)

    Quote Originally Posted by kib2 View Post
    No, not at all. I think we must wrap it using SIP, like QScintila does.
    That's what I thought. I thought about giving it a try some time ago but it looked like a lot of work (no automating as far as I could tell).

    Quote Originally Posted by kib2 View Post
    Here's my report on trying to build QCodeEdit 2.1:
    http://share11.appspot.com/3421
    The file which causes compilation to fail should not even be compiled actually... It is a remnant from the early genesis of the syntax engine (I had to test it outside of the editing framework to make sure it worked properly before integrating it into the bigger entity). You can safely remove this file (lib/qnfa/main.cpp). Then re-run qmake, then make and everything should go fine.

    Thanks for reporting this. I'll remove this file from the next release (it is already removed from SVN btw).
    Current Qt projects : QCodeEdit, RotiDeCode

  10. #9
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QTextEdit column select ?

    FullMetalCoder,

    I've removed main.cpp from "\lib\qnfa", then the corresponding line from "qcodeedit-2.1.pro" (I suppose I have to do that too).
    Here's what I've got : http://share11.appspot.com/3222

    I did not find any Edyuk versions < 0.9 to study the old code ...where are they ?

    I've installed Edyuk for the first time : really great piece of work

    Is it possible to continue talking on IRC or by mail ?

  11. #10
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit column select ?

    Quote Originally Posted by kib2 View Post
    I've removed main.cpp from "\lib\qnfa", then the corresponding line from "qcodeedit-2.1.pro" (I suppose I have to do that too).
    Here's what I've got : http://share11.appspot.com/3222
    Errr... Would you, by any chance, have generated a qmake project with "qmake -project" ? (The main project file should be qcodeedit.pro which is a subdirs project for the lib and the example app). This would explain why everything goes wrong.

    Quote Originally Posted by kib2 View Post
    I did not find any Edyuk versions < 0.9 to study the old code ...where are they ?
    The TuxFamily download server only provide the most recent packages. All the versions are available on sourceforge : http://sourceforge.net/project/showf...kage_id=191461

    Quote Originally Posted by kib2 View Post
    I've installed Edyuk for the first time : really great piece of work
    Thanks. And version 1.1.0 will be even better

    Quote Originally Posted by kib2 View Post
    Is it possible to continue talking on IRC or by mail ?
    Sure. You can use the MSN address in my profile to contact me by mail or IM
    Current Qt projects : QCodeEdit, RotiDeCode

  12. #11
    Join Date
    Jun 2013
    Posts
    13
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit column select ?

    Dear fullmetalcoder,
    I'm a beginner and now I'm also get stucked in the column select in QPlainTextEdit, could you please help me with this? Thanks a lot!!

Similar Threads

  1. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  2. Replies: 0
    Last Post: 10th November 2006, 13:46
  3. Sql Server cannot retrieve data from select
    By Atomino in forum Qt Programming
    Replies: 10
    Last Post: 7th September 2006, 16:37
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  5. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 08:00

Tags for this Thread

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.