Zelber
25th December 2015, 21:21
Hello.
I extended Qlabel class with mousePressEvent to create my_qlabel:
my_qlabel.cpp
#include "my_qlabel.h"
#include <QMouseEvent>
#include <QDebug>
my_qlabel::my_qlabel(QWidget* parent) : QLabel(parent)
{
}
void my_qlabel::mousePressEvent(QMouseEvent *event)
{
{
if(event->button() == Qt::LeftButton)
{
int xwsp=event->x();
int ywsp=event->y();
emit leftClickAction(xwsp,ywsp);
}
else if(event->button() == Qt::RightButton)
emit rightClickAction();
}
}
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->label, SIGNAL(leftClickAction(int,int)), this, SLOT(leftclick(int,int)));
connect(ui->label, SIGNAL(rightClickAction()), this, SLOT(rightclick()));
QPixmap pix("filelocation");
QPixmap pixr = pix.scaledToHeight(600,Qt::SmoothTransformation);
QPixmap * wsk_pixr;
QPixmap * wsk_pix;
wsk_pixr = & pixr;
wsk_pix= & pix;
setrs(wsk_pixr);// sets resized pix on myqlabel.
}
Everything is working fine, but the question is: how can i pass "pix" or pointer to "pix"(Images are supposed to be around 10 mb each , so I assume passing pointer is much more time efficient than passing whole image.) created on program startup to "leftclick" or "rightclick" functions?
I extended Qlabel class with mousePressEvent to create my_qlabel:
my_qlabel.cpp
#include "my_qlabel.h"
#include <QMouseEvent>
#include <QDebug>
my_qlabel::my_qlabel(QWidget* parent) : QLabel(parent)
{
}
void my_qlabel::mousePressEvent(QMouseEvent *event)
{
{
if(event->button() == Qt::LeftButton)
{
int xwsp=event->x();
int ywsp=event->y();
emit leftClickAction(xwsp,ywsp);
}
else if(event->button() == Qt::RightButton)
emit rightClickAction();
}
}
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->label, SIGNAL(leftClickAction(int,int)), this, SLOT(leftclick(int,int)));
connect(ui->label, SIGNAL(rightClickAction()), this, SLOT(rightclick()));
QPixmap pix("filelocation");
QPixmap pixr = pix.scaledToHeight(600,Qt::SmoothTransformation);
QPixmap * wsk_pixr;
QPixmap * wsk_pix;
wsk_pixr = & pixr;
wsk_pix= & pix;
setrs(wsk_pixr);// sets resized pix on myqlabel.
}
Everything is working fine, but the question is: how can i pass "pix" or pointer to "pix"(Images are supposed to be around 10 mb each , so I assume passing pointer is much more time efficient than passing whole image.) created on program startup to "leftclick" or "rightclick" functions?