Hi Henry,

> What would the best approach be? (Utils::MacroExpander could probably
> be good enough for inserting the date but what about the time.)

Beside CurrentDate, there is also a CurrentTime variable in different flavors.

Regards,
André

On 2025-06-19 22:51, apoenitz wrote:
Hi.

On Wed, Jun 18, 2025 at 06:05:08PM +0200, Henry Skoglund wrote:
Hi, just updated to Qt Creator 17 and it looks good, however when rebuilding
my Qt Creator plugin I got stuck for a bit with this failing:

   auto pe =
qobject_cast<QPlainTextEdit*>(EditorManager::currentEditor()->widget());

For almost 15 years that statement served me well and it allowed for example
setting a fatter cursor at Qt Creator start (useful on 4K screens) but
today, it returns a nullptr :-(


Instead, the new incantation for Qt Creator 17 (and onwards?) seems to be:

   auto pe = qobject_cast<Utils::PlainTextEdit*>(EditorManager::currentEditor()->widget());

After that fix, it's smooth sailing (Utils::PlainTextEdit behaves 100%
compatible with QPlainTextEdit).

But if there was a bit of documentation of this new class in the Utils::
Namespace I would be even more happy!
Sorry to hear that this bit you.

I guess nobody expected that some plugin out there had a hard dependency
on Editor::widget() being in fact a QPlainTextEdit for text editors.

The fact that Utils::PlainTextEdit behaves like QPlainTextEdit is not
quite an accident, the idea is add a few features and try to upstream
it to Qt proper again. For this to happen it has to stay compatible.

In case this upstreaming will be  successful there's a good chance that
Utils::PlainTextEdit will vanish again. But then there'll hopefully
be a more communication.

Thanks for answering, it's all working fine now with the new Utils::PlainTextEdit.

Perhaps I'm doing it wrong, i.e. I shouldn't take a hard dependency on the built-in editor being of a certain class.

Say I were to write a new plugin to Qt Creator having only one command, like F5 in Notepad in Windows: inserting the current date and time where the text cursor is.

What would the best approach be? (Utils::MacroExpander could probably be good enough for inserting the date but what about the time.)


--
Qt-creator mailing list
Qt-creator@qt-project.org
https://lists.qt-project.org/listinfo/qt-creator

Reply via email to