1、出现问题如下:
源码:
#ifndef MYLISTWIDGETITEM_H
#define MYLISTWIDGETITEM_H
#include <QObject>
#include <QListWidget>
#include <QListWidgetItem>
class MyListWidgetItem : public QListWidgetItem
{
Q_OBJECT
public:
explicit MyListWidgetItem(QListWidget *view );
};
解决:自定义类中包含了Q_OBJECT 宏,而他的父类不是QObject的子类,所以会报错。比如我这里的QListWidgetItem就不是QObject的子类,所以把该宏去掉即可。
2、中文乱码
如果出现界面中文乱码,在对应的cpp文件中加上以下语句即可。
#pragma execution_character_set("utf-8")