Hi how can I insert into my graphics scene vector image? QT supports only svg files? or some other files (eps, ps...) too? If yes, so what?
Hi how can I insert into my graphics scene vector image? QT supports only svg files? or some other files (eps, ps...) too? If yes, so what?
Unless you provide an image plugin for reading such files, you'll have to convert them to some supported format.
could you give me some hint, how to convert to supported format? thanks
i tried thisbut it doesnt workQt Code:
void MainWindow::loadVectorImage() { "*.pdf *eps *.ps *.svg"); QPicture picture; if (fileName.isEmpty() || !picture.load(fileName)) return;// loading to image QPixmap imageNew; QPainter painter; painter.begin(&imageNew); // paint in imageNew painter.drawPicture(0, 0, picture); // draw the picture at (0,0) painter.end(); // set vector image to scene image into scene scene->openImage(imageNew); }To copy to clipboard, switch view to plain text mode![]()
You have to use some application that is able to read your format and write one of supported formats. To see what formats are supported by your installation of Qt, use QImageReader::supportedImageFormats().
so I should use svg? Because QImageReader::supportedImageFormats() are bitmap file, arent they?
At some point you will have to convert your vector image to bitmap anyway, so it's your choice when to do it. If you want to go for svg, that's fine.
thanks but I dont know how I should to convert vector image to pixmap...
when I tried this code (I wrote it in this thread) it doesnot work.
Then I found thisand Alex answer is similar with my code
load vector image into QPicture
but nothing happensQt Code:
QPicture picture; picture.load(fileName)) imageNew.fill(); painter.drawPicture(0, 0, picture);// paint to paniterTo copy to clipboard, switch view to plain text mode
edit: so problem could be in "picture.load(fileName)" but I dont know why, I though that QPicture::load it should be ok but it isnot![]()
Last edited by Noxxik; 10th March 2009 at 23:00.
I don't see a point of loading the image to the picture and them immediately trying to put it on a pixmap. You could load it to the pixmap directly. By the way, if you have an svg image, you have to use QSvgRenderer to transfer it to a pixmap.
sorry for my stupid answers, could you help me once again how I should to load a vector image? I thought that I tried to load vector image in QPicture to the pixmap directly.
svg images dont have to be default, rather I would like to load image in pdf or in eps file
I already told you you can't load a postscript image to Qt applications directly, because neither of these formats are supported. You have to convert your vector image to some other supported format using a 3rd party application such as Gimp or ImageMagick and then load it into Qt. You can also use a 3rd party library (such as poppler for PDF) to do that inside your application. In the end you will have to have a raster representation of the image, regardless if you use PDF, EPS, SVG or PNG. The only thing you can decide is when to do the conversion and what resolution to use in case of vector graphics.
thanks I am trying poppler library, but it writes me one error, when I try to compile my programme
my compilor mingw wrote this error
undefined reference to '_imp___ZN7Poppler8Document4loadERK7QStringRK10QBy teArrayS6_'
but I dont know where I have mistake
I wrote this...
Do you know where I have mistake please? or what could I have do? pleaseQt Code:
"*.pdf"); Poppler::Document *document = Poppler::Document::load(fileName); // this is the error if (!document/* || document->isLocked()*/) { // delete document; return; }To copy to clipboard, switch view to plain text mode
Bookmarks