QString bitek
= ui
->lineEdit
->text
();
bool ok;
int bitek2 = bitek.toInt(&ok,10);
if(!ok)
QMessageBox::information(this, tr
("Baj van."),tr
("Az ok %1 ").
arg(ok
));
else{
int kbitek2 = int(pow(2,bitek2));
QPixmap pixmap
(bitek2
*10, kbitek2
*10 );
// pixmap.fill(Qt::green);
painter.setBrush(Qt::black);
painter.setPen(Qt::white);
for(int i=0;i<kbitek2;i++){
// ulong g = gray_code(i);
QString itt
= print_bin2
("", gray_code
(i
), bitek2
);
for(int j=0;j<bitek2;j++){
if(itt[j]=='1'){
painter.setBrush(Qt::black);
painter.drawRect(j*10, i*10, 10,10);
// painter.drawPoint(j,i);
}
else if (itt[j]=='.') {
painter.setBrush(Qt::cyan);
painter.drawRect(j*10, i*10, 10,10);
}
}
}
ui->imageLabel->setPixmap(pixmap);
qDebug()<<pixmap.depth();
// ui->imageLabel->resize(bitek2,kbitek2);
ui->imageLabel->adjustSize();
}
QString bitek = ui->lineEdit->text();
bool ok;
int bitek2 = bitek.toInt(&ok,10);
if(!ok)
QMessageBox::information(this, tr("Baj van."),tr("Az ok %1 ").arg(ok));
else{
int kbitek2 = int(pow(2,bitek2));
QPixmap pixmap(bitek2*10, kbitek2*10 );
// pixmap.fill(Qt::green);
QPainter painter( &pixmap );
painter.setBrush(Qt::black);
painter.setPen(Qt::white);
for(int i=0;i<kbitek2;i++){
// ulong g = gray_code(i);
QString itt = print_bin2("", gray_code(i), bitek2);
for(int j=0;j<bitek2;j++){
if(itt[j]=='1'){
painter.setBrush(Qt::black);
painter.drawRect(j*10, i*10, 10,10);
// painter.drawPoint(j,i);
}
else if (itt[j]=='.') {
painter.setBrush(Qt::cyan);
painter.drawRect(j*10, i*10, 10,10);
}
}
}
ui->imageLabel->setPixmap(pixmap);
qDebug()<<pixmap.depth();
// ui->imageLabel->resize(bitek2,kbitek2);
ui->imageLabel->adjustSize();
}
To copy to clipboard, switch view to plain text mode
Bookmarks