저는 몇 달 동안 Qt를 사용해 왔습니다. 다양한 버전의 코드를 작성하고 다시 작성하는 방법을 통해 나 자신을 가르치고 있습니다. QML, XML, C++, Gui.Qt 신호와 xml 슬롯
이 접근 방식은 나에게 많은 통찰력을 제공합니다. 하지만 나는 붙어 있습니다. 아래의 코드는 주로 XML로 모든 것을 수행합니다. 하지만 신호와 슬롯을 작동시키지 못합니다. 모든 것이 나에게 잘 보이고 나는 뭔가를 놓친다 고 생각합니다.
<ui version="4.0">
<class>enTry1</class>
<widget class="QMainWindow" name="enTry1">
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>All xml signals and slots example</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>70</x>
<y>75</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Pushbutton</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>70</x>
<y>125</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Pushbutton_2</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>46</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>enTry1</receiver>
<slot>button1pressed()</slot>
<hints>
<hint type="sourcelabel">
<x>113</x>
<y>138</y>
</hint>
<hint type="destinationlabel">
<x>207</x>
<y>136</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>enTry1</receiver>
<slot>button2pressed()</slot>
<hints>
<hint type="sourcelabel">
<x>127</x>
<y>199</y>
</hint>
<hint type="destinationlabel">
<x>206</x>
<y>183</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>button1pressed()</slot>
<slot>button2pressed()</slot>
</slots>
</ui>
버튼을 누르면 더 많은 정보를 얻으려면 코드가 아무 것도 실행되지 않습니다. 오류는 말한다;
QObject::connect: No such slot QLabel::button1pressed() in ./ui_entry1.h:69
QObject::connect: (sender name: ‘pushButton’)
QObject::connect: (receiver name: ‘label’)
QObject::connect: No such slot enTry1::button2pressed() in ./ui_entry1.h:70
QObject::connect: (sender name: ‘pushButton_2’)
QObject::connect: (receiver name: ‘enTry1’)
제안 사항 ....
답장을 보내 주시면 감사하겠습니다. 나는 내가 자동으로 코드를 생성한다는 것을 알았습니다. 나는 그 때 그것이 그렇게 초조하게 만들었던 것이라고 생각한다. 나는 그걸 이후 버너에 놓고 미해결 문제로 썼다. 늦게 답장을 보내서 유감스럽게 생각하며 도움을 주셔서 대단히 감사드립니다. –