rm ingored
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
#include <QWheelEvent>
|
||||
#include "imageview.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
ImageView::ImageView(QWidget *parent) :
|
||||
QLabel(parent) {
|
||||
|
||||
// std::cout << this->geometry().height() << " " << this->geometry().width() << std::endl;
|
||||
}
|
||||
|
||||
// ImageView::ImageView(QWidget *parent, std::string path):
|
||||
// QLabel(parent) {
|
||||
// this->setPixmap(QPixmap(QString::fromStdString(path)));
|
||||
// }
|
||||
|
||||
void ImageView::wheelEvent(QWheelEvent *event) {
|
||||
QPointF shift = event->position();
|
||||
QRegion r = QRegion();
|
||||
// this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(10, 10, this->rect(), &r);
|
||||
this->scroll(shift.x(), shift.y(), this->rect());
|
||||
// this->setPixmap(QPixmap());
|
||||
// pm.scroll(shift.x(), shift.y(), this->rect());
|
||||
|
||||
// pm.scroll();
|
||||
// this->setPixmap(pm);
|
||||
|
||||
//this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(shift.x(), shift.y(), this->pixmap()->rect());
|
||||
|
||||
QPoint numDegrees = event->angleDelta() / 8;
|
||||
std::cout << numDegrees.x() << std::endl;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void ImageView::setImage(std::string image){
|
||||
//Commented is a way of scaling that is, as I understand, is lossless. If there'll be problems with current method's losses, I'll return to commented method
|
||||
|
||||
maxHeight = this->height();
|
||||
maxWidth = this->width();
|
||||
|
||||
QPixmap pixmap = QPixmap(QString::fromStdString(image));
|
||||
// double scaleFactor = pixmap.height() > pixmap.width()? static_cast<double>(maxHeight) / pixmap.height() : static_cast<double>(maxWidth) / pixmap.width();
|
||||
|
||||
pixmap = pixmap.scaled(maxWidth, maxHeight, Qt::AspectRatioMode::KeepAspectRatio);
|
||||
|
||||
|
||||
this->setPixmap(pixmap);
|
||||
|
||||
// this->setGeometry(this->geometry().x(), this->geometry().y(), pixmap.width() * scaleFactor, pixmap.height() * scaleFactor);
|
||||
// this->setScaledContents(true);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef IMAGEVIEW_H
|
||||
#define IMAGEVIEW_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
class ImageView : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
double maxHeight, maxWidth;
|
||||
public:
|
||||
ImageView(QWidget *parent=nullptr);
|
||||
// ImageView(QWidget *parent=nullptr, std::string path="");
|
||||
void wheelEvent(QWheelEvent*);
|
||||
void setImage(std::string);
|
||||
};
|
||||
#endif // IMAGEVIEW_H
|
||||
Reference in New Issue
Block a user