問題タブ [qproperty]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Q_PROPERTY をデザイン ビューに表示する方法
Q_PROPERTY を持つ QPushButton から派生したクラスがありますが、デザイン モードのプロパティ エディターに表示されません。
デザイン ビューでカスタム クラスにプロモートされた QPushButton があり、少なくとも "int" 型のプロパティがプロパティ エディタに自動的に表示されると思います。簡単なことを誤解している可能性が高いです。
コード内の関連する行は次のようになります。
コードは正常にコンパイルされます。
qt - 2つの異なるcppからqmlテキストを更新するには?
私はqmlプロジェクトを持っています。
StackPage.qml にテキスト (id:cnt という名前) があり、firstclass.cpp と secondclass.cpp からこのテキストを更新する必要があります。
Q_PROPERTY の定義は firstclass.h にあり、setCntText 関数は firstclass.cpp にあります。
setCntText(i) によって firstclass.cpp からテキストを更新し、setCntText(0) を呼び出して secondclass.cpp から更新しようとします。
secondclass から m_cntText 変数を設定できますが、qml テキスト (id:cnt という名前) を更新できませんでした。
main.cpp
ファーストクラス.cpp
セカンドクラス.cpp
ファーストクラス.h
secondclass.h
main.qml
StackPage.qml