Hi All,
Is there any way to hide/erase the border of the QRect.
Hi All,
Is there any way to hide/erase the border of the QRect.
Since a QRect is just a data class and has no visualization, how are you drawing the rectange?
Cheers,
_
I am drawing it on the pdf using QPainter on QPrinter.
I want to draw QRect rect without borders.Qt Code:To copy to clipboard, switch view to plain text mode
If you RTFM of QPainter::drawRect(), you will see that it uses the current pen and the current brush. The pen is what controls how the border is drawn. Just set the appropriate pen, then.
Thanks for the reply,
I have just written the below LOC for setting the width of the QPen just before the QRect,
Qt Code:
pen.setWidth(0); reportPainter.setPen(pen); //DRAWING RECTANGLE ON THE PDF reportPainter.drawRect(rect ); reportPainter.drawText(rect , Qt::AlignCenter | Qt::TextWordWrap, "SOME TEXT INSIDE");To copy to clipboard, switch view to plain text mode
But this isn't helping. It is drawing the rectangle with the same width (as it was before writing above LOC for setting the width of QPen).
Again, the doc for QPen says it all: "A line width of zero indicates a cosmetic pen. This means that the pen width is always drawn one pixel wide, independent of the transformation set on the painter."
Qt's documentation is great. I suggest you read the whole documentation of the classes you use before posting here. That is what I just did; I had never drawn a rectangle in a QPainter but I found the answers to your questions there.
Hi,
Are you sure that now have you readed all QPen Doc?
It tooks me only 30 seconds to discover that the pen have a style, and you can set it to "no pen".
Òscar Llarch i Galán
Shame on you. I just told you to read the documentation and you keep spamming the forum without doing so; yes, that means reading the whole page. The answer to your question is right there. Had you put as much effort into solving your own problem as I have, this whole thing would have been over an hour ago.
OK, now that someone has given a major clue, I might as well "disclose" the sentence you were too lazy to read: "Setting the style to Qt::NoPen tells the painter to not draw lines or outlines." There. How difficult was it?
Alternatively you can use QPainter::fillRect().
Cheers,
_
I'm not sure I understand the motivation for all the negativity here. Sure, reading the fine manual can be a very helpful thing. However, leveraging Google to immediately find a solution to a problem can be much faster. As a result of this fine person having asked the question, I found my answer more quickly.
And it only took you 6 1/3 years after this was posted in June 2014. Fast work. Good for you.I found my answer more quickly.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Seems to me the OP's original complaint was that calling drawRect() drew a rectangle. There was no specific request or attempt to draw a filled rectangle, so the quickest way to fix the "problem" was to not call drawRect().
Quite surprised that nobody picked that up at the time.
Hah, you're right. I guess everyone focused on the topic of the post and didn't look closely enough at the code.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
True. I've spent much of the weekend on Google trying to understand why I can no longer connect to my NAS server from Windows 10. But sometimes Google remembers too much. Posts dating from Windows NT days aren't helpful.
Last edited by d_stranz; 8th November 2020 at 22:06.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks