It's already showing DoorControl1 Dialog with Plane's image...
still as you said I added ODoorControl1->show(); in Bifold constructor ,but no line still drawn..
It's already showing DoorControl1 Dialog with Plane's image...
still as you said I added ODoorControl1->show(); in Bifold constructor ,but no line still drawn..
you have to simplify and go step at a time.
Put your dialog in main, and show it.
See if you get the line drawn then.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I have added draw line code in main.cpp itself but still it only shows image and no line is drawn
main.cppQt Code:
#include <QtGui/QApplication> #include <QtCore> #include <QtGui> #include <QLabel> //#include "bifold.h" int main(int argc, char *argv[]) { // BiFold w; // w.show(); QLabel l; l.resize(pixmap.size()); painter.setPen(Red); painter.drawLine(250,300,500,300); painter.end(); l.setPixmap(pixmap); l.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
Is this a fault of my image,but I tried changing the image still no line is drawn..
I read in documentation of QPainter "Painting on a QImage with the format QImage::Format_Indexed8 is not supported."
But my image format is QImage::Format_RGB32.
I m not able to upload image here,it says "upload failed"
pls show me right direction ,I cannot proceed my work if this issues is not solved.
Are you sure that your resource file path is good?
Your code with some minor tweaks and a local file:
Input is:Qt Code:
#include <QtCore> #include <QtGui> #include <QDebug> int main(int argc, char *argv[]) { QLabel l; QPixmap pixmap; qDebug() << goodLoad << pixmap.isNull() << pixmap.size() << pixmap.depth(); painter.setPen(Red); painter.drawLine(40, 40, 200, 280); painter.end(); pixmap.save("./test2.png"); l.setPixmap(pixmap); l.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
test.jpg
Output is:
andQt Code:
To copy to clipboard, switch view to plain text mode
test2.jpg
Edit: the forum converted the PNG files to JPG
Finally the line is visible over the image
The co-ordinates I used for drawing line were main culprit here
painter.drawLine(250,300,500,300);
if I use ur co-ordinate,Qt Code:
also qDebug() << goodLoad << pixmap.isNull() << pixmap.size() << pixmap.depth(); shows To copy to clipboard, switch view to plain text mode
painter.drawLine(40, 40, 200, 280);
line is drawn.....
My next query is
Can we directly paint QDialog ?
I need to draw some arcs, squares and lines on QDialog
You can paint on any widget, but only in a paintEvent().
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
hai to every one am new to qt actually am trying to draw line on image (qpixmap),i had tried all coeds u have given above but still i didnt get the result plz can any one give full code to me thanking you and sorry for my bad english
How to drag that line over the image?
I tried to drag. But it does not update.
Bookmarks