Unsolved QLabel + QImage Error.
-
@Pada_ said in QLabel + QImage Error.:
I'm importing QImgae from the clipboard and converting it to Pixmapd.
How?
"However, if you save the image to the clipboard without a path and paste it, it is created without the path." - paste where?
I really don't understand what you're doing. Where exactly do you do Ctrl-v? -
QGraphicsScene, as I said before.
There is an item in the sceneItem that deals with the image, but it is not the same as me.
I did not put it anywhere. Just the label of the new projet and the way I told you before, there's an RGB mark in the corner.
-
Hi
Im not sure what tool that is. ?
Seems not to be installed in my windows. -
use this tool.
-
Ok.
But i cant get to it to paste anything to a QGraphicsView .
Nothing happens.
Did you write some code to allow this ? -
QGraphicsView I'm working on it, so you can do it with Ctrl + V.
In addition to QGraphicsView, the result is the same even if you create a new project and set the Image stored in the Clipboard in the QLabel.
-
Capture the image with the capture tool and do not save it. Then click the right mouse button and click Copy. It will then enter the Clipboard.
-
Run it as my source.
-
Looking at the left corner or the corners of the image, you will see the RGB dots.
QClipboard *clipboard = QApplication::clipboard();
if(!clipboard)
return;
test source !
#include "mainwindow.h"
#include "ui_mainwindow.h"#include <QBuffer>
#include <QClipboard>
#include <QMimeData>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QClipboard *clipboard = QApplication::clipboard(); if(!clipboard) return; const QMimeData *mimeData = clipboard->mimeData(); if(!mimeData) return; if(mimeData->hasImage()) { QImage image = qvariant_cast<QImage> (mimeData->imageData()); ui->label->setPixmap(QPixmap::fromImage(image)); }
}
MainWindow::~MainWindow()
{
delete ui;
} -
-
Hi
Using your code and paste to QLabel did not show RGB dots
What Qt version are you using ?
-
I am using Qt5.4 version and Windows8 64Bit.
The same phenomenon came out on Windows10 64Bit.
I did it with the same source, but did not come out with RGB dots like the picture?
Can I check the source?
-
@Pada_
Which source ?
I used your QClipboard *clipboard = QApplication::clipboard(); code and a blank project with QLabel. -
I also tested it with the source I wrote.
But it looks like a picture. I do not know where the problem is.
-
@Pada_
Are you saying the code you show here and QLablel works but
in real program it don't with QGraphicsView ?Would it be possible to test with a newer Qt version ?
5.4 is pretty old. -
-
@Pada_
nope. i dont have 5.4.