Qt5:"Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document."错误

当遇到该错误的时候,要检查几个方面

1、*.ui  文件是否执行了打开操作

        QFile    file("mainwindow.ui");
        file.open(QFile::ReadOnly);

2、有没有将  *.ui   文件拷贝到debug 和 release 目录下

3、有没有在工程文件中加入以下语句

    CONFIG  +=  uitools

4、另外, 在qt5 中 , QUiLoader  头文件的位置为 <QtUiTools/QUiLoader>

原文地址:https://www.cnblogs.com/wowk/p/3111932.html