Solve some inexplicable errors such as QT: Forward Declaration of 'struct UI: XXX'; invalid use of incomplete struct "UI: widget"

Source: Internet
Author: User

Tag: QT

During the UI design of QT widgets today, I changed the widget object name. After multiple successful compilation operations, I performed cleanup and re-build, there are a lot of inexplicable errors:

Widget. h: 12: Error: Forward Declaration of 'struct UI: components'

Widget. cpp: 8: Error: Invalid use of incomplete type 'struct UI: components'


Online Search finds that every time you create a new key on the qt design interface, QT automatically generates yyy. ui files, such as widgets. UI, Because I directly created a GUI program and also generated the corresponding class and widget, I changed the UI object name, but the class still uses the class name of widget, therefore, errors may occur.


The solution is to first Delete the ui_widget.h (corresponding to XXX. UI) generated by MOC, and then set the interface object name,

Namespaceui {

Classwidget;

}

Class Name. In this case, modify the name of the widget or dialog or mainwindow In the UI to the widget in the "struct UI: widget" mentioned in the error. In short, keep the class item value in the UI file the same as the objectname of the widget, dialog, or mainwindow In the ui!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.