0

我正在尝试将我的项目从 Qt5 移植到 Qt6。我的问题是 UIC 生成的代码如下所示:

QObject::connect(SelectHome, &QToolButton::clicked, toQPSQLSettingUI, qOverload<>(&QWidget::selectHome));

MSVC2019 编译失败:

ui_toqpsqlsettingui.h(74,101): error C2039: 'selectHome': is not a member of 'QWidget'
C:\Qt\6.0.4\msvc2019_64\include\QtWidgets\qcompleter.h(57): message : see declaration of 'QWidget'
C:\Users\I542264\source\repos\tora\src\ui_toqpsqlsettingui.h(74,1): error C2065: 'selectHome': undeclared identifier

看到目标是方法是QWidget::selectHome,所以恕我直言MSVC是正确的:QWidget没有方法selectHome。但是目标应该是子类方法toQPSQLSettingUI::selectHome

设计师截图

完整的源代码在这里。最初为Qt2创建,迁移到Qt3=>Qt4=>Q5。

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>toQPSQLSettingUI</class>
 <widget class="QWidget" name="toQPSQLSettingUI">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>600</width>
    <height>517</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="minimumSize">
   <size>
    <width>600</width>
    <height>0</height>
   </size>
  </property>
  <property name="windowTitle">
   <string>Form1</string>
  </property>
  <layout class="QGridLayout">
   <property name="margin">
    <number>11</number>
   </property>
   <property name="spacing">
    <number>6</number>
   </property>
   <item row="0" column="1" colspan="2">
    <widget class="QLineEdit" name="PGSQL_HOME"/>
   </item>
   <item row="0" column="0">
    <widget class="QLabel" name="TextLabel6_2_2_2">
     <property name="toolTip">
      <string>The default dateformat to use when querying the database.</string>
     </property>
     <property name="text">
      <string>PgSQL home</string>
     </property>
     <property name="wordWrap">
      <bool>false</bool>
     </property>
     <property name="buddy">
      <cstring>PGSQL_HOME</cstring>
     </property>
    </widget>
   </item>
   <item row="1" column="0">
    <spacer name="verticalSpacer">
     <property name="orientation">
      <enum>Qt::Vertical</enum>
     </property>
     <property name="sizeHint" stdset="0">
      <size>
       <width>20</width>
       <height>40</height>
      </size>
     </property>
    </spacer>
   </item>
   <item row="0" column="3">
    <widget class="QToolButton" name="SelectHome">
     <property name="text">
      <string>...</string>
     </property>
    </widget>
   </item>
  </layout>
 </widget>
 <tabstops>
  <tabstop>PGSQL_HOME</tabstop>
 </tabstops>
 <resources/>
 <connections>
  <connection>
   <sender>SelectHome</sender>
   <signal>clicked()</signal>
   <receiver>toQPSQLSettingUI</receiver>
   <slot>selectHome()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>606</x>
     <y>20</y>
    </hint>
    <hint type="destinationlabel">
     <x>314</x>
     <y>258</y>
    </hint>
   </hints>
  </connection>
 </connections>
 <slots>
  <signal>signal1()</signal>
 </slots>
</ui>
4

0 回答 0