QString filename= QFileDialog::getOpenFileName(this,"open picture"); image.load(filename); QSqlQuery query; QByteArray ba; QBuffer buf( &ba ); buf.open( QIODevice::ReadWrite); image.save( &buf, "XPM" ); buf.close(); query.prepare("INSERT INTO users (login,pass,role,foto) VALUES (:log, :pas, :rol,:fotko);"); query.bindValue(":log",m_ui->login->text()); query.bindValue(":pas", m_ui->pass->text()); query.bindValue(":rol", m_ui->role->currentText()); query.bindValue(":fotko", ba ); query.exec();
QString im=m_ui->tableWidget->item(row,0)->text(); query.prepare("Select foto from users where login=:log"); query.bindValue(":log",im); query.exec(); QByteArray ba; m_ui->label->setBackgroundRole(QPalette::Base); m_ui->label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); m_ui->label->setScaledContents(true); while (query.next()) { ba = query.value( 0 ).toByteArray(); QPixmap pixmap(ba); m_ui->label->setPixmap( pixmap ); }
double qwe=ba.length(); m_ui->doubleSpinBox->setValue(qwe); QPixmap pixmap(ba); m_ui->label->setPixmap( pixmap );
QPixmap pixmap; pixmap.loadFromData(ba); m_ui->label->setPixmap( pixmap );