joshy198
19th September 2012, 21:28
in Levels.h
#ifndef MYWINDOW_H
#define MYWINDOW_H
#include <QPushButton>
#include <QMessageBox>
#include <QMainWindow>
#include <QHBoxLayout>
#include "QScrollArea"
#include "QImage"
#include "QLabel"
#include "QWidget"
#include "QVBoxLayout"
#include "QGroupBox"
#include "QSpacerItem"
#include "QList"
class Levels: public QMainWindow
{
Q_OBJECT
public:
Levels(){};
~ Levels(){};
void erzeugen(Levels *level);
void setzeBilder();
private:
QVBoxLayout *ramen;
QVBoxLayout *layout;
QImage *image;
QList<QLabel *> labels;
QPushButton *back;
QWidget *central;
QGroupBox *box;
QScrollArea *area;
QSpacerItem *space;
QList<QString *> bilder;
//public slots:
};
#endif
in levels.cpp
#include "levels.h"
void Levels::erzeugen(Levels *level)
{
setzeBilder();
central=new QWidget(this);
ramen= new QVBoxLayout(central);
setCentralWidget(central);
box = new QGroupBox;
back = new QPushButton(" ? Back");
for(int i=0;i<12;i++)
{
labels << new QLabel();
}
for(int i=0;i<12;i++)
{
labels.at(i)->setBackgroundRole(QPalette::Dark);
labels.at(i)->setAutoFillBackground(true);
image = new QImage(bilder.at(i));//Muss im debug-Ordner sein!!!
labels.at(i)->setPixmap(QPixmap::fromImage(*image));
labels.at(i)->setMaximumHeight(image->height());
labels.at(i)->setMaximumWidth(image->width());
}
space = new QSpacerItem(1,10);
for(int i=0;i<12;i++)
{
layout->addWidget(labels.at(i));
}
box->setLayout(layout);
area = new QScrollArea;
area->setWidgetResizable(false);
area->setWidget(box);
}
void Levels::setzeBilder()
{
for(int i=0;i<12;i++)
{
bilder << new QString;
}
bilder.at(0)=QString::fromStdString("l01.png");
bilder.at(1)=QString::fromStdString("l02.png");
bilder.at(2)=QString::fromStdString("l03.png");
bilder.at(3)=QString::fromStdString("l04.png");
bilder.at(4)=QString::fromStdString("l05.png");
bilder.at(5)=QString::fromStdString("l06.png");
bilder.at(6)=QString::fromStdString("l07.png");
bilder.at(7)=QString::fromStdString("l08.png");
bilder.at(8)=QString::fromStdString("l09.png");
bilder.at(9)=QString::fromStdString("l10.png");
bilder.at(10)=QString::fromStdString("l11.png");
bilder.at(11)=QString::fromStdString("l12.png");
}
And i Get lots of Error-Messages ...(25) which are probably allways the same...
Is there a way to set the list at the class where this class is called?
#ifndef MYWINDOW_H
#define MYWINDOW_H
#include <QPushButton>
#include <QMessageBox>
#include <QMainWindow>
#include <QHBoxLayout>
#include "QScrollArea"
#include "QImage"
#include "QLabel"
#include "QWidget"
#include "QVBoxLayout"
#include "QGroupBox"
#include "QSpacerItem"
#include "QList"
class Levels: public QMainWindow
{
Q_OBJECT
public:
Levels(){};
~ Levels(){};
void erzeugen(Levels *level);
void setzeBilder();
private:
QVBoxLayout *ramen;
QVBoxLayout *layout;
QImage *image;
QList<QLabel *> labels;
QPushButton *back;
QWidget *central;
QGroupBox *box;
QScrollArea *area;
QSpacerItem *space;
QList<QString *> bilder;
//public slots:
};
#endif
in levels.cpp
#include "levels.h"
void Levels::erzeugen(Levels *level)
{
setzeBilder();
central=new QWidget(this);
ramen= new QVBoxLayout(central);
setCentralWidget(central);
box = new QGroupBox;
back = new QPushButton(" ? Back");
for(int i=0;i<12;i++)
{
labels << new QLabel();
}
for(int i=0;i<12;i++)
{
labels.at(i)->setBackgroundRole(QPalette::Dark);
labels.at(i)->setAutoFillBackground(true);
image = new QImage(bilder.at(i));//Muss im debug-Ordner sein!!!
labels.at(i)->setPixmap(QPixmap::fromImage(*image));
labels.at(i)->setMaximumHeight(image->height());
labels.at(i)->setMaximumWidth(image->width());
}
space = new QSpacerItem(1,10);
for(int i=0;i<12;i++)
{
layout->addWidget(labels.at(i));
}
box->setLayout(layout);
area = new QScrollArea;
area->setWidgetResizable(false);
area->setWidget(box);
}
void Levels::setzeBilder()
{
for(int i=0;i<12;i++)
{
bilder << new QString;
}
bilder.at(0)=QString::fromStdString("l01.png");
bilder.at(1)=QString::fromStdString("l02.png");
bilder.at(2)=QString::fromStdString("l03.png");
bilder.at(3)=QString::fromStdString("l04.png");
bilder.at(4)=QString::fromStdString("l05.png");
bilder.at(5)=QString::fromStdString("l06.png");
bilder.at(6)=QString::fromStdString("l07.png");
bilder.at(7)=QString::fromStdString("l08.png");
bilder.at(8)=QString::fromStdString("l09.png");
bilder.at(9)=QString::fromStdString("l10.png");
bilder.at(10)=QString::fromStdString("l11.png");
bilder.at(11)=QString::fromStdString("l12.png");
}
And i Get lots of Error-Messages ...(25) which are probably allways the same...
Is there a way to set the list at the class where this class is called?