Important: Please read the Qt Code of Conduct -

[SOLVED]Using QTextEdit multiple times

  • Hello!

    I have encountered a possible bug, maybe there is a resolution for this problem so I thought I should post it here first, and then in the bugtracker.


    I am using around 16 QTextEdit objects in my window to display various information which must be able to be copied via copy/paste from Windows. However, when I try to copy this, my application crashes on multiple systems. If I do not try to copy everything works fine, i get all the data and display it correctly. Anyone else encountered this problem or am I the only one? :)

    Thank you for your help nonetheless.

    Qt 5.1.1 Windows 7 Proffesional x86, MSVC2010

  • Hi,
    How does your code looks like? Isn't there a bug in your copy/paste algorithm??? Don't blame Qt until your absolute sure ;-)

  • I did not modify anything on the copy/paste i let the Framework handle this... I just use setFixedSize for each element, and append strings when a button is clicked :)

  • bumpiddy bumpiddy bump

  • Ok, place your code, You might use pointers that are unavailable etc.

  • Correct me if I'm wrong, but using pointers that are unavailable wouldn't crash the app when I'm using those pointers? My window displays normally untill I try to use Copy on the text displayed on any of the QTextEdit objects that have text in them... And another fun fact is that this is a multiple window app, and on one other window the QTextEdit works fine, this is why i am assuming it is because I am using multiple QTextEdit objects in one window... The code is not so complicated, it just has a header with the declaration of all objects, a source file with the allocation of each object (16 labels, 16 buttons and 16 text edits) with 16 slots that are only called for each button press... Again it is not in my code the error, because I can close / open the window as many times i want, but only if I try to copy the text will it result in a crash...

  • I still don't believe it's the QTextEdit class that is at fault. Why would it?? The copy function copies data to the notepad/temp holder. Then when pasting it should be available to anyone pasting it. So, no code, no proper answer ;-)
    I'll test it here, simple form, two textedits and let's see if it crashes..........
    btw, just because you don't share code, do you use the canPaste() function??
    Nup, no problem on my end!!!! Two QTextBrowsers next to each other, I'm able to paste without crashes etc!!! Check your code, it's faulty!

  • After fiddling around with the debugger i saw that it throws an exception at line 289 in qwindowsclipboard.cpp, which is:

    QString mimeDataFormats = mimeData ?
    mimeData->formats().join(QStringLiteral(", ")) : QString(QStringLiteral("NULL"));

  • Like I said, it isn't Qt to blame ;-)
    Why do you need to alter the input text?? Adding the , character? How does the rest of that function look like?
    Shouldn't you also check the hasformats() function on the mimeData? And how do you fill the mimeData pointer (if it's a pointer at all??)
    More code to be of any assistance!

  • That is from the Qt standard classes. Not from one of my own classes. That is where the debugger shows an exception... The odd part is that when i tried to reproduce the error I couldn't... I do not need to alter the text, it is text that i receive from Win32 API classes (Like owner name etc) and I convert from Variant (because i have different CIMTYPEs) and I save them in QString or QStringList depending on the method, after which I display them... When I try to copy from the QTextEdit objects, it crashes... Which is weird... I tried to add simple text but it didn't work either... I am stumped

  • This is a pretty big issue now, only with the complete program or at least more source code someone may be of assistance. Good luck with this issue. Maybe you need to change some things and try a different approach? Maybe specify why you need the copy/paste with so many QTextEditors, btw QTextBrowser is the more modern class to use. Some text functions have been added to QTextEditor

  • Nevermind... I am kinda dumb... Had a CoUninitialize() call that screw me over... :) Thx for your time though :)

Log in to reply