Hi everybody,
I'm just a new to qt!
I'm going to implement a project, that I need to draw an unknown number of images on screen.
I tried 3 methods, but none of them worked.
1.
I tested QLabel for drawing a picture by the use of "pixmap".
As I said I need to paint an unknown number of images.[n*m, e.g. 2 or 6,...]
I tried like this... with the thought that this will add several(here 2) labels(pix) to my MainWindow:
label_1->setPixmap(*pixmap_and);
label_1->adjustSize();
label_1->move(100,100);
QLayout *layout_1
= this
->layout
();
layout_1->addWidget( label_1 );
label_1->move(200,200);
layout_1->addWidget( label_1 );
this->setLayout(layout_1);
QPixmap *pixmap_and = new QPixmap("../pix/AND.png");
QLabel *label_1 = new QLabel(this);
label_1->setPixmap(*pixmap_and);
label_1->adjustSize();
label_1->move(100,100);
QLayout *layout_1 = this->layout();
layout_1->addWidget( label_1 );
label_1->move(200,200);
layout_1->addWidget( label_1 );
this->setLayout(layout_1);
To copy to clipboard, switch view to plain text mode
I doesn't work! 
I found that for drawing several images using QLabels I need to create several number of QLabels.
I tried to use a "vector" of "QLable". Unfortunately I couldn't do it because of several syntax problems.
would you guide me how can I implement that? (If it is possible!)
2.
I also tried QImage and QPainter.
I implemented a code like this :
QImage image
("../pix/AND.png");
if (!image.isNull())
ui->label->setText("Image Loaded! ");
qpainter.drawImage(100,100,image);
image.load(":/pix/AND.png");
qpainter.drawImage(100,100,image);
QImage image("../pix/AND.png");
if (!image.isNull())
ui->label->setText("Image Loaded! ");
QPainter qpainter(this);
qpainter.drawImage(100,100,image);
image.load(":/pix/AND.png");
qpainter.drawImage(100,100,image);
To copy to clipboard, switch view to plain text mode
As you see I used both pix in my hard and Qt resources. The image is sucsessfuly loaded. But I dont see anything
on screen. Is there any problem in my code?
3. I also tried this:
pixmap_tmp.load("../pix/AND.png");
qpainter.drawPixmap(200,200,50,50,pixmap_tmp);
pixmap_tmp.load(":/pix/AND.png");
qpainter.drawPixmap(200,200,50,50,pixmap_tmp);
QPixmap pixmap_tmp;
pixmap_tmp.load("../pix/AND.png");
qpainter.drawPixmap(200,200,50,50,pixmap_tmp);
pixmap_tmp.load(":/pix/AND.png");
qpainter.drawPixmap(200,200,50,50,pixmap_tmp);
To copy to clipboard, switch view to plain text mode
again I didn't see anything on screen. ?!
Thanks in advance for further helps,
Bookmarks