记录用Qt做程序设计大作业遇到的问题以及解决方法

时隔两年多重拾Qt,当时只是瞎玩,现在可是正儿八经做UI版的大作业,算是第一个正经项目。

问题1:C++多文件编译报错“multiple defination of XXX”或“undefined reference to XXX”,加#progama once#ifndef无效

从未接触过多文件编译,这次吃了大麻烦。
解决方法:https://blog.csdn.net/hyyjiushiliangxing/article/details/100899284

问题2:Qt项目中,设计器画好的窗口控件,运行后却不更新

经检查发现是debug目录下的mainwindow.ui没有随着项目构建而更新。
解决方法:https://www.freesion.com/article/17061247855/
https://blog.csdn.net/u011831805/article/details/123831545
正解:后来发现原来是.pro文件乱掉了,.ui文件没放到正确的位置。按照下面的规范放置即可:

点击查看代码
SOURCES += \
        main.cpp \
        mainwindow.cpp \
    io.cpp \
    public.cpp \
    init.cpp \
    datastr.cpp

HEADERS += \
        mainwindow.h \
    public.h \
    io.h \
    datastr.h \
    define.h \
    init.h

FORMS += \
        mainwindow.ui \

RESOURCES += \
    image.qrc

posted @ 2022-06-09 00:44  yige_2019  阅读(120)  评论(0编辑  收藏  举报
/**/