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
I think yes... I have at top of file.cpp this...
#include <src/poppler-qt4.h>
in src folder I have all which is in "poppler-0.10.4\qt4\src"
edit: or I should add reference src/poppler-qt4.h to myprogram.pro ?
edit2: or I should add some folder to "Qt\4.4.1\src\3rdparty" or some oter place?
Last edited by Noxxik; 11th March 2009 at 15:53.
This only includes the header file into the compilation unit.
You should add an entry similar to: to your project file and rerun qmake.edit: or I should add reference src/poppler-qt4.h to myprogram.pro ?
edit2: or I should add some folder to "Qt\4.4.1\src\3rdparty" or some oter place?
So I tried it how you wrote me...
So in programm.pro I have
but mingw wrote me, that it dont find -lpoppler it wrote this:Qt Code:
TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . LIBS += -lpoppler # Input HEADERS += mainscene.h \ # other *.h file SOURCES += main.cpp \ # other *.cpp file RESOURCES += images.qrc RC_FILE = icon.rcTo copy to clipboard, switch view to plain text mode
I dont know where I add some this filesC:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot find -lpoppler
I didn't say you had to copy exactly what I wrote. Please open QMake docs and see what the LIBS variable does and what to put in it.
so I read thisbut I dont understand very well how to add poppler file to my project
if I would add something like this win32:LIBS += c:/mylibs/math.lib in poppler-0.10.4 I didnt find any lib files or I have to install poppler? I dont know how it install in windows
Noxxik (13th March 2009)
So I should find some manual how to install in windows, but I cannot find any manual. I tried find something, but instalation in windows it is not so easy
I remove poppler library and I add only svg images. So thank you for help
I send you thanks
Bookmarks