我从我的设计类中调用它,稍后将它们添加到布局中,但我总是收到该函数的错误消息ladeBild(QLabel l, QString s)
void Levels::erzeugen(Levels *)
{
....
ladeBild(l01,"l01.png");
ladeBild(l02,"l02.png");
ladeBild(l03,"l03.png");
ladeBild(l04,"l04.png");
ladeBild(l05,"l05.png");
ladeBild(l06,"l06.png");
ladeBild(l07,"l07.png");
ladeBild(l08,"l08.png");
ladeBild(l09,"l09.png");
ladeBild(l10,"l10.png");
ladeBild(l11,"l11.png");
ladeBild(l12,"l12.png");
...
}
void Levels::ladeBild(QLabel l,QString s)
{
l = new QLabel();
l.setBackgroundRole(QPalette::Dark);
l.setAutoFillBackground(true);
image = new QImage(s);//Muss im debug-Ordner sein!!!
l.setPixmap(QPixmap::fromImage(*image));
l.setMaximumHeight(image->height());
l.setMaximumWidth(image->width());
}
我收到以下错误消息(对于每次调用ladeBild
)
In member function 'void Levels::erzeugen(Levels*)': Fehler:no matching function for call to 'Levels::ladeBild(QLabel*&, const char [8])' candidates are: void Levels::ladeBild(QLabel, QString) Fehler:no match for 'operator=' in 'l = (QFlags<Qt::WindowType>(0u), (operator new(20u), (<statement>, ((QLabel*)<anonymous>))))' candidates are: QLabel& QLabel::operator=(const QLabel&)`
无法解决这个问题...