Results 1 to 2 of 2

Thread: App crashes on error ASSERT: "n" in file ..\..\include\QtGui/private/../../../src/gui

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default App crashes on error ASSERT: "n" in file ..\..\include\QtGui/private/../../../src/gui

    Hi,
    i'm trying to do simple formating function with QTextCursor in QPlainTextEdit, but still don't understand why my example app crashes with error:
    Qt Code:
    1. Starting C:\Qt\Projects\untitled-build-desktop\debug\untitled.exe...
    2. ASSERT: "n" in file ..\..\include\QtGui/private/../../../src/gui/text/qfragmentmap_p.h, line 291
    3. C:\Qt\Projects\untitled-build-desktop\debug\untitled.exe exited with code 3
    To copy to clipboard, switch view to plain text mode 

    I have this simple code:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. this->edit=new QPlainTextEdit(this);
    5. this->setCentralWidget(this->edit);
    6. connect(edit->document(),SIGNAL(contentsChange(int,int,int)),this,SLOT(contentsChange(int,int,int)));
    7. }
    8.  
    9. void MainWindow::contentsChange(int position,int charsRemoved,int charsAdded) {
    10. if (this->edit->toPlainText().length()>10) {
    11. QTextCursor *curA=new QTextCursor(this->edit->document()->findBlock(0));
    12. QTextCharFormat charFormat;
    13. charFormat.setFontItalic(true);
    14. curA->setPosition(0,QTextCursor::MoveAnchor);
    15. curA->setPosition(4,QTextCursor::KeepAnchor);
    16. curA->beginEditBlock();
    17. if (curA->hasSelection()) {
    18. curA->mergeCharFormat(charFormat);
    19. curA->clearSelection();
    20. }
    21. curA->endEditBlock();
    22. delete curA;
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 

    I'm trying to create simple function which formats specified number of characters from specified position (something like setFormat(int position,int length)) with QTextCursor, but my function is crashing because of mentioned error, so i have prepared simple example to show you way how i'm trying to do it.
    Attached Files Attached Files

Similar Threads

  1. Replies: 32
    Last Post: 25th August 2012, 23:10
  2. Replies: 9
    Last Post: 20th May 2010, 09:55
  3. Replies: 2
    Last Post: 6th October 2009, 01:09
  4. "Treat wchar_t as Built-in Type" to "yes" link error
    By sungaoyong in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 11:45
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 15:58

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.