English 中文(简体)
变式设计师的习俗
原标题:Qt Designer custom plugin and dynamic properties

我正试图写出一套习惯性植被,作为Qt Designer plugin。 其中一些财产与我的所有植被相同,因此,我想作一个基类。 但是,存在多重继承的问题,当基类继承QObject时(由于Q_PROPERTY宏观,使其财产在Qt设计商中符合要求),习俗植被必须成为QWidget的子女。 但是,我发现Qt的有活力的财产,因此,基底阶级获得植被点,并拥有有活力的财产。

class BaseClass {
  QWidget *widget;
  BaseClass(QWidget *widget) {
    this->widget = widget;
    this->widget->setProperty("Some", 0.0);
  }
  void setSome(double some) {
    this->widget->setProperty("Some", some);
  }
...

.。 我可以确定有活力的财产,看着它们,把他们 in在Qt设计器上,所有这一切都是ok。 我想从财产中读出的东西是错误的。 当我使用:

this->widget->property("Some").value<double>();

标识设计师没有开始(!)

当我再一次使用时

QVariant var = this->widget->property("Some");
return var.toDouble();

它是同一个问题! Qt设计商没有发出任何信息或其他信息。 我正在使用4.7.4号盖特及其设计师。 same造物设计商(在2.0.0、2.0.1号测试)也有同样的可变性。

我错了吗?

感谢任何建议!

问题回答

在制造另一组QWidget时,QWidget被传给建筑商,实际上就是父母,因此如果你把一些东西用作生产物的话。

Derived::Derived(QWidget* parent):Base(parent){

}

你们将把这一财产交给父母而不是子女。

页: 1 Qt打算在提及QObjects时使用简单的继承制,创建具有确定Q_PROPERTY的职能的基类,并增加一些宏观因素,以确定所需财产。

希望会有所助益。





相关问题
Qt: Do events get processed in order?

If I had a class A, where one of its functions does: void A::func() { emit first_signal(); emit second_signal(); } Assuming that a class B has 2 slots, one connected to first_signal, and the ...

How to determine how much free space on a drive in Qt?

I m using Qt and want a platform-independent way of getting the available free disk space. I know in Linux I can use statfs and in Windows I can use GetDiskFreeSpaceEx(). I know boost has a way, ...

Drag & drop with .ui files

I m having big troubles with drag & drop. I ve created a new Qt Designer Form Class in which I have one QListWidget and one QWidget. Now I want to enable dragging & dropping between these two ...

Link errors on Snow Leopard

I creating a small desktop application using Qt and Poco on Mac OS X Snow Leopard. Qt works fine, but once I started linking with Poco I get the following warning: ld: warning: in /Developer/SDKs/...

Showing two windows in Qt4

My friend and I have each created parts of a GUI using Qt 4. They both work independently and I am trying to integrate his form with the my main window. As of now this is the code I am using to try ...

Qt equivalent of .NET data binding?

Is there an equivalent of .NET s data binding in Qt? I want to populate some combo boxes and other widgets with QStrings that refer to specific entities in my database. However, it would be cleaner ...

热门标签