Qt6迁移-UIC生成的代码无法编译(连接插槽)-已更新
我正在尝试将我的项目从Qt5移植到Qt6。 我的问题是UIC生成的代码如下所示:Qt6迁移-UIC生成的代码无法编译(连接插槽)-已更新,qt,qt6,uic,Qt,Qt6,Uic,我正在尝试将我的项目从Qt5移植到Qt6。 我的问题是UIC生成的代码如下所示: QObject::connect(SelectHome, &QToolButton::clicked, toQPSQLSettingUI, qOverload<>(&QWidget::selectHome)); 请看目标是方法是QWidget::selectHome,因此我认为MSVC是正确的QWidget没有方法selectHome。但目标应该是子类methodtoQPSQLSett
QObject::connect(SelectHome, &QToolButton::clicked, toQPSQLSettingUI, qOverload<>(&QWidget::selectHome));
请看目标是方法是QWidget::selectHome
,因此我认为MSVC是正确的QWidget没有方法selectHome
。但目标应该是子类methodtoQPSQLSettingUI::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>
toQPSQLSettingUI
0
0
600
517
0
0
600
0
表格1
11
6.
查询数据库时使用的默认日期格式。
PgSQL主页
假的
PGU主页
Qt::垂直
20
40
...
PGU主页
选择家
点击()
toQPSQLSettingUI
selectHome()
606
20
314
258
信号1()
此行:
说明toQPSQLSettingUI
的类是QWidget
。但是为了使用selectHome
槽(我认为它确实存在于子类中),您需要将小部件“升级”到子类(这是通过在Qt-Creator设计模式中右键单击小部件,然后选择升级操作完成的)。
<?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>