Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Paragraph style based rich text edit with qt
Qt 6.11 is out! See what's new in the release blog

Paragraph style based rich text edit with qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 483 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    French Paragon
    wrote on last edited by
    #1

    Hello, I'm working on an application for comic, fiction book and pen&paper rpg universe development, inspired by the old desktop version of celtx. I'd like to be able to attach simple rich text to a hierarchy of items like characters, places, ... and then refer to them in some other texts.

    My requirements are:

    • all the styles are given by paragraph metadata, and only by the paragraph metadata.
    • some kind of hierarchy has to be maintained between the paragraph, ideally the documents chapters and sub-chapters can be explored via a QTreeView.
    • paragraph styles and their hierarchy is enforced by the type of text edited, none can be defined by the user.
    • The text styles can contain some prefix and/or suffix like chapter numbering.
    • Editor must be responsive to it parent width and idealy show all the text.
    • small errors in margin and inter-paragraph linebreak are not a problem.
    • Links to other items in the project can be added in the text and some ref-counting mechanism can be synchronized with those links.

    I looked for documentation and examples all over the internet and found nothing very clear, but I have two ideas:

    • First, subclass QTextEdit to capture a few events, especially to capture line breaks. Then use a nested series of QTextFrames to store the paragraphs with the associated styles. It has the advantages to be simple (most of rich text edit functions are already implemented in Qt) but lacks some flexibility (for examples to manage chapter numbers, or references, which as almost to be done "by hand").

    • Or, create something based on the model/view framework, which has the advantages to have a very clear way of storing data and document structure, but lack some simplicity, as QTreeView has to be adapted as a rich text editor using a mix of appropriate item delegates and event handling.

    What do think ? Do you see any critical problem with those approaches ? Do you see another, better approach ? Do you have any examples of applications which did something similar ?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved