Any Qt + Python devs out there with any experience on calling deleteLater() from the Python side?
I have some costly dialogs I want cleared on close, and so far I've been running deleteLater() in the closeEvent, which is clearly a little risky. I do get the very rare segfault especially if I close one particular dialog which has a QTimer singleShot call. If the deleteLater() is called when it is running, I get a RunTImeError.
I have experimented with a lot of solutions, including sip.delete and setting Qt.WA_DeleteOnClose, and those are even worse (kind of expected).
What I've tried now is to call setParent(None) instead in the closeEvent, and that definitely triggers the class del on the Python side, and seems to reduce the number of QWidgets in the app back to the expected value.
Anyone with some experience with this that can advice?
There is definitely an issue here arising from Qt and Python both having a garbage collector that don't really talk to each other.
The easy solution is to not tell Qt to do anything at all, and just keep adding more stuff into memory, or try to re-use dialogs. However, re-use comes with the complication of having to clear old content first, and I also have dialogs that are used in multiple instances simultaneously with different content.
Yes, deleteLater is clearly risky. I believe it is safe for on-the-fly generated context menus, which I delete after the exec call returns, but I really want a better solution for dialogs.
This week, plus four more weeks until I can start my summer vacation. Four full weeks of no meetings and no work. Can't wait! Already counting down.
Sometimes I think that I would like to take a sabbatical, like a full year, to do other things. But I also know that last time I was between jobs* for three months, I got very bored.
I was literally between jobs. As in, I had a new job contract, but was waiting for a security clearance to go through so I could start.
The QTextDocument really needs better support for HTML. I just gave up on it for my own project and I'm now building documents with QTextBlockFormat and QTextCharFormat instead.
The ODT writer is also very limited. I already implemented my own a long time ago.
@carlschwan The issue in QPlainTextEdit (and QPlainTextDocument) is that it has a much simplified layout engine based on a fixed line height. I suspect that's why it's not there. But neither editor has a line height default property. It has to be set on the text block level, which is inconvenient. The plain text layout engine ignores this setting in either case. At least last time I looked at the source (probably 6.4-6.5 or something).
What it is, in the end, is a completely unsourced answer. You're just getting a couple of paragraphs as an answer to your query, with absolutely NO friggin' idea where the information came from.
If you cannot vet information, it is WORSE than useless. It can cause damage if it's wrong. We're already seeing some scary and dangerous "answers" from Google's AI for example.
I much prefer a list of normal Internet search results. Sure, some of them might be COMPLETE bullshit, but at least I can see WHERE the information is coming from, and decide what to trust based on the reputation of the sites in question.
Just... No thanks, Google, Microsoft, etc. Please remove this garbage that's making your services worse.
People who think I was hash against the book should read it. But then really, actually read all of the words, and not give up, skim and start just looking at pictures and headlines.