简体   繁体   English

Qt设计器的自定义选项卡小部件插件创建

[英]Custom Tab Widget Plugin Creation for Qt designer

We're building a custom tab widget for our project and I'm creating a Designer plugin for it. 我们正在为项目构建一个自定义选项卡小部件,并为此创建一个Designer插件。 I'm having trouble getting the same functionality as the standard tab widget. 我在获取与标准选项卡小部件相同的功能时遇到了麻烦。

I'd like to have our widget mimic the same behavior to: 1) allow changing tab inside of designer by clicking the tabs 2) show "browned out" properties (eg, if no tabs are on the widget) 我希望我们的小部件模仿相同的行为:1)通过单击选项卡允许在设计器内部更改选项卡2)显示“变色”属性(例如,如果小部件上没有选项卡)

I've created a collection and property extension for the widget, and I've got it to add/insert/delete tabs, but I haven't been able to find out how to do these two things. 我已经为小部件创建了集合和属性扩展,并且已经添加/插入/删除了选项卡,但是我还无法找到如何完成这两件事的方法。

Is the source code for the tab widget plugin available somewhere? 选项卡小部件插件的源代码在某处可用吗? Or does anyone know how which methods to attach to the widget from designer to do this? 还是没有人知道设计师可以通过哪些方法将其附加到小部件上?

I found the Designer source under the QtSDK folder and located the piece that appears to deal with clicks. 我在QtSDK文件夹下找到了Designer源,并找到了用来处理点击的部分。 it looks like what they do is when the plugin creates the widget they attach an event handler to the widget using installEventFilter(). 当插件创建窗口小部件时,他们看起来就像在做什么,他们使用installEventFilter()将事件处理程序附加到窗口小部件。

The handler then checks for left mouse clicks and sends a command to designer to set the currentIndex property to the correct value. 然后,处理程序检查是否有鼠标左键单击,并向设计器发送命令以将currentIndex属性设置为正确的值。

The source to check it out is in qdesigner_tabwidget.cpp. 签出的源在qdesigner_tabwidget.cpp中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM