Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3244088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:30:34+00:00 2026-05-17T18:30:34+00:00

How to create a bulleted or numbered list in QTextEdit with Qt by clicking

  • 0

How to create a bulleted or numbered list in QTextEdit with Qt by clicking a button? Also it is necessary that make a list the paragraphes which are selected by clicking the same button. And when the cursor is in the list and you click the button, the the list item becomes not-list item, but a simple paragraph. In two words I want to create for my text editer 2 buttons, that work in the same way as (buletting and numbering button is MS Word).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:30:35+00:00Added an answer on May 17, 2026 at 6:30 pm

    I have used this code:

     void TextEdit::textStyle(int styleIndex)
     {
         QTextCursor cursor = textEdit->textCursor();
    
         if (styleIndex != 0) {
             QTextListFormat::Style style = QTextListFormat::ListDisc;
    
             switch (styleIndex) {
                 default:
                 case 1:
                     style = QTextListFormat::ListDisc;
                     break;
                 case 2:
                     style = QTextListFormat::ListCircle;
                     break;
                 case 3:
                     style = QTextListFormat::ListSquare;
                     break;
                 case 4:
                     style = QTextListFormat::ListDecimal;
                     break;
                 case 5:
                     style = QTextListFormat::ListLowerAlpha;
                     break;
                 case 6:
                     style = QTextListFormat::ListUpperAlpha;
                     break;
                 case 7:
                     style = QTextListFormat::ListLowerRoman;
                     break;
                 case 8:
                     style = QTextListFormat::ListUpperRoman;
                     break;
             }
    
             cursor.beginEditBlock();
    
             QTextBlockFormat blockFmt = cursor.blockFormat();
    
             QTextListFormat listFmt;
    
             if (cursor.currentList()) {
                 listFmt = cursor.currentList()->format();
             } else {
                 listFmt.setIndent(blockFmt.indent() + 1);
                 blockFmt.setIndent(0);
                 cursor.setBlockFormat(blockFmt);
             }
    
             listFmt.setStyle(style);
    
             cursor.createList(listFmt);
    
             cursor.endEditBlock();
         } else {
             // ####
             QTextBlockFormat bfmt;
             bfmt.setObjectIndex(-1);
             cursor.mergeBlockFormat(bfmt);
         }
     }
    

    from this source.

    Only I have changed

     } else {
         // ####
         QTextBlockFormat bfmt;
         bfmt.setObjectIndex(-1);
         cursor.mergeBlockFormat(bfmt);
     }
    

    to the following code:

     } else {
         // ####
    QTextBlockFormat bfmt;
    bfmt.setObjectIndex(0);
    cursor.mergeBlockFormat(bfmt);
    setTextCursor(cursor);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use rb-appscript to create a new Pages document that contains bulleted
How can I create a bulleted list in ReportLab? The documentation is frustratingly vague.
How do I create a databound, bulleted list of hyperlinks in WPF? I've got
Create Pex test to test a DLL and hardware controlled by that DLL? I
How should I format my cell to have a bulleted list of items. Currently
In .NET, is there a namespace that has built in button images such as
I have the following WordML snippet which works well for numbered lists : <w:wordDocument
(ASP.NET Web Application) I'd like to create a page which allows the user to
// Create a scanner that reads from the input stream passed to us CSLexer
I have a template where I've created a custom list style, and ensured that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.