自动标签和检查变量是否已定义

发布于 2024-11-19 06:21:31 字数 333 浏览 4 评论 0原文

出色地。现在我再次有一些问题。基本上我在做两件事。自动制表,例如,当您执行 if() 时,您按 Enter 键并转到下一行,但您不执行 TABS 使其看起来像这样:

if(a=1)
    //Basically, the line tabbed

系统检查是否定义了变量。就像,你这样做:

QString Haha = "Haha";
Haha.blabla();

嗯,基本上当你没有定义“QString Haha”时,Haha.blabla 不会被着色。知道如何检查 X 变量是否已定义吗?

谢谢!

Well. Now again, i have some questions. Basically i'm doing two things. Autotabbing which is for example when you do if() you press enter and you go to next line, but you don't do the TABS to make it appear look like this:

if(a=1)
    //Basically, the line tabbed

And the system to check if a variable is defined. Like, you do:

QString Haha = "Haha";
Haha.blabla();

Well, basically when you don't define "QString Haha" the Haha.blabla wouldnt be colored. Any idea of how to check if X variable has been defined?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随心而道 2024-11-26 06:21:31

如果你要做一个功能齐全的代码编辑器,你确实需要实现对编辑的编程语言的解析。这意味着大量的工作。例如,QtCreator 确实解析 C++,并且 QtCreator 的源代码可用,因此您可以从中检查需要多少工作。

您可以使用 QSyntaxHighlighter 进行简单的模式匹配语法着色。

If you are going to do a fully featured code editor, you really need to implement parsing of the edited programming language. And that means a lot of work. For example, QtCreator does parse C++ and QtCreator's source code is available, so you could check from that how much work is required.

You can do a simple pattern matching syntax coloring using QSyntaxHighlighter.

孤城病女 2024-11-26 06:21:31

关于自动标签,您可以尝试查看 keyPressEvent

[编辑]
删除了有关变量定义的部分,因为我弄错了您的帖子,抱歉。
Roku 链接的语法荧光笔类在语法突出显示方面可能是最好的;-)

About the autotabbing, you could try looking into keyPressEvent.

[Edit]
Removed the part about variable definition as I got your post wrong, sorry.
The Syntax highlighter class linked by Roku will probably be for the best when it comes to syntax highlighting ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文