Hi! Thanks for your reply. Here is the example that fails. Basically it loads a photo into a label and then saves it:
void MainWindow::on_savePushButton_clicked()
{
[...]
if (!photoLabel
->pixmap
()->save
(QString("fotos/%1.jpg").
arg(regLineEdit
->displayText
()),
0,
100)) QMessageBox::warning(this, qApp
->applicationName
(),
"Error");
[...]
}
void MainWindow::loadPhoto()
{
QString path
= QString("fotos/%1.jpg").
arg(cardsModel
->index
(mapper
->currentIndex
(), ViewCardsTableModel
::Registration).
data().
toString());
if (!pixmap.load(path))
{
QMessageBox::critical(this, qApp
->applicationName
(),
QString("Error.").
arg(cardsModel
->index
(mapper
->currentIndex
(), ViewCardsTableModel
::Registration).
data().
toString()));
}
else
photoLabel->setPixmap(pixmap);
}
void MainWindow::on_savePushButton_clicked()
{
[...]
if (!photoLabel->pixmap()->save(QString("fotos/%1.jpg").arg(regLineEdit->displayText()), 0, 100))
QMessageBox::warning(this, qApp->applicationName(), "Error");
[...]
}
void MainWindow::loadPhoto()
{
QPixmap pixmap;
QString path = QString("fotos/%1.jpg").arg(cardsModel->index(mapper->currentIndex(), ViewCardsTableModel::Registration).data().toString());
if (!pixmap.load(path))
{
QMessageBox::critical(this, qApp->applicationName(), QString("Error.").arg(cardsModel->index(mapper->currentIndex(), ViewCardsTableModel::Registration).data().toString()));
photoLabel->setPixmap(QPixmap());
}
else
photoLabel->setPixmap(pixmap);
}
To copy to clipboard, switch view to plain text mode
Bookmarks