【问题标题】:uic: Unexpected element nameuic:意外的元素名称
【发布时间】:2012-05-25 08:27:34
【问题描述】:

我正在尝试使用 qmake 和 Qt4 编译 .pro 文件以从 qttestrunnerlib.pro 获取库,但我收到此错误:

~/docs/UT_Cpp_Test/main/cppDir/src/qttestrunner$ qmake qttestrunnerlib.pro 
uic: Error in line 6, column 14 : Unexpected element name
uic: Error in line 6, column 14 : Unexpected element name

当我使用 Qt3 时,它可以工作,并且我成功获得了我的库。但我想将它升级到 Qt4。可能吗?我该怎么办?

【问题讨论】:

    标签: compilation qt4 qmake cppunit test-runner


    【解决方案1】:

    我使用了 qt3-support 包中的 uic3(至少在 gentoo 上)

    uic3 -convert ui-file-qt3.ui -o ui-file-qt4.ui

    【讨论】:

      【解决方案2】:

      那是因为qt4中的设计师和qt3不同。表示qt3和qt4生成的ui文件不一样。 That's why the unexpected element name error!

      The uic reads a user interface definition (.ui) file in XML as generated by Qt
      Designer and creates corresponding C++ header or source files.
      
      Easiest way to solve is, use your qt4 ide to open you form and it will ask for 
      conversion.Then use the newly created ui for your compilation. 
      

      【讨论】:

      • 谢谢您的回答,您的意思是我应该用 ide(我可以使用 qt creator)打开每个文件 .ui 并在我的编译中重用转换后的文件还是什么?
      • 是的,您需要通过使用 qtcreator 打开它来将其转换为与 qt4 兼容的 ui。或者尝试 uic -o MyGUI.h MyGUI.ui,前提是你有 qt4 环境。构建项目不需要gui.ui,只需要ui_gui.h。
      • 对不起,我试图用 qtcreator 打开它,但它没有接受它,我尝试uic -o MyGUI.h MyGUI.ui ,但我得到同样的错误~/docs/UT_Cpp_Test/main/cppDir/src/qttestrunner$ uic -o testbrowserdlg.h testbrowserdlg.ui uic: Error in line 6, column 14 : Unexpected element name File 'testbrowserdlg.ui' is not valid
      • 尝试使用 .pro 文件用 qt4 qtcreator 打开整个项目
      • 是的,我做了什么我在 qtcreator 中打开了 .pro,然后我尝试打开 testbrowserdlg.ui,双击文件时出现错误,使用 qt Designer 它告诉我它是' n 一个有效的 UI 设计器文件!!!!!!!!!
      猜你喜欢
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      • 2014-09-30
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多