QPixmap Problem
-
@ofmrew said in QPixmap Problem:
In what folder did the file from pixmap.save( "path.png" ); end up.
Depends, it can be saved at Home(root directory) or in the project output folder. I tried in Ubuntu.
-
@ofmrew said in QPixmap Problem:
I had to convert your program into a console application
So, hadn't have an error when QApplication header was not detected? In the console application, GUI is removed... So it causes errors.
Create a Qt Widget Application, then insert the code and compile. It should work in that way!
-
What I meant was when you executed the code you posted, in what folder did you find the path.png file?
-
This one is working fine. I get a white image with several rectangles on it
#include <QCoreApplication> #include <QFile> #include <QImage> #include <QPainter> #include <QPointF> #include <QtDebug> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QImage parcelMap(20000, 10000, QImage::Format_ARGB32); parcelMap.fill(Qt::white); QPainter pm(&parcelMap); static const QPointF points1[5] = { QPointF(200, 200), QPointF(20000-200, 200), QPointF(20000-200, 5000-100), QPointF(200, 5000-100), QPointF(200, 200)}; pm.drawPolyline(points1, 5); static const QPointF points2[5] = { QPointF(200, 5000+100), QPointF(10000-100, 5000+100), QPointF(10000-100, 5000-100), QPointF(200, 5000-100), QPointF(200, 200)}; pm.drawPolyline(points2, 5); static const QPointF points3[5] = { QPointF(10000+100, 5000+100), QPointF(20000+200, 5000+100), QPointF(20000+200, 5000-100), QPointF(10000+100, 5000-100), QPointF(10000+100, 200)}; pm.drawPolyline(points3, 5); pm.end(); QFile file("parcels.png"); if (!file.open(QIODevice::WriteOnly)) { qDebug() << "Failed to open file" << file.errorString(); } parcelMap.save(&file, "PNG"); return 0;
-
There's an upload image button just above the editor, third from the right.
-
@SGaist I have narrowed the problem to my Mint Linux computer because I moved the one above to a Win 10 computer and I got a white rectangle with just visible rectangles. I moved the .png file to the Win 10 machine and, guess what, it showed a white rectangle with just visible rectangles. So the problem appears to be Image Viewer. Which viewer do you use on Linux computers.
As for the icons on the editor, to tell the truth, I never really noticed them. Is the some documentation on their meaning and how to use them. Most are obvious, but link, picture, zen mode and the one on the end, require more explanation.
Seems we spent all this time running to ground a non-problem with Qt, while the real culprit was software provided by the operating system; however, just for grins I tried GIMP Image Viewer and of course it showed the image correctly. Warning to Mint Linux users, Image Viewer is not to be trusted.
Thanks to all for the help.
-
It depends on the desktop environment so there are several possible like Gwenview, Okular, etc.
Zen mode simply puts the editor in full screen so you don't have any distraction and the last one on the right allows to easily insert code sample.