You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Ilan

Trainee

  • "Ilan" is male
  • "Ilan" started this thread

Posts: 78

Location: Israel

Occupation: Software engineer

  • Send private message

1

Sunday, April 4th 2004, 10:26am

Drawing a stippled line

I'm trying to draw a line that has width and its interior is stippled (using a user-defined pattern).
I'm able to do so when drawing a circle - using QBrush::setPixmap and pen size of 0.
The lines are drew using pen size = line width.
The problem is that QBrush does not seems to affect the interior of the lines that has a width, but only 'closed shapes'.

Does anybody has an idea except of drawing the line as a polygon (slow solution)?

axeljaeger

Professional

  • "axeljaeger" is male

Posts: 730

Location: Frankfurt Germany

Occupation: Student

  • Send private message

2

Sunday, April 4th 2004, 12:33pm

QBrush is a fill pattern. You probably want to have a look at QPen.
It's nice to be important but it's more important to be nice

Ilan

Trainee

  • "Ilan" is male
  • "Ilan" started this thread

Posts: 78

Location: Israel

Occupation: Software engineer

  • Send private message

3

Sunday, April 4th 2004, 12:51pm

I'm using QBrush to set the pattern for non-line elements. If there is a way to use it also for lines, I don't mind.
The problem is that it seems to be no effect using QBrush on lines, so you probably right and I have no choice but using QPen. But QPen does not support patterns at all (just a number of dotted lines types).

Any idea how I can get it going?

axeljaeger

Professional

  • "axeljaeger" is male

Posts: 730

Location: Frankfurt Germany

Occupation: Student

  • Send private message

4

Sunday, April 4th 2004, 1:37pm

You want to fill an outline using a bitmap pattern? I think this is not easy possible with Qt. An idea would be to make a polygon out of the outline part.
It's nice to be important but it's more important to be nice

Torf

Beginner

  • "Torf" is male

Posts: 13

Location: Germany

  • Send private message

5

Sunday, April 4th 2004, 2:02pm

RE: Drawing a stippled line

Attention: Newbie answer ahead ;)

You could "fake" your line using a rectangle. You would have to calculate the angle of your line (against a horizontal or vertical line) and use QPainter.rotate(angle) with that angle.
With a rectangle, it should be no problem to fill the interior...

See chapter 9 of Qt Turorial 1 for an example: http://doc.trolltech.com/3.2/tutorial1-09.html

This post has been edited 1 times, last edit by "Torf" (Apr 4th 2004, 2:02pm)


Ilan

Trainee

  • "Ilan" is male
  • "Ilan" started this thread

Posts: 78

Location: Israel

Occupation: Software engineer

  • Send private message

6

Sunday, April 4th 2004, 4:00pm

RE: Drawing a stippled line

Drawing using a rectangle might be a problem in cases where we wish to draw a line with round caps.
On the other hand, it might be faster to draw a rectangle + 2 circles at both ends instead of making a polygon out of the line.
But if we need to substract half a circle from each end so it will not clear itself in trueColor display (color over color clears it), then this calculation becomes even more expesive than making a polygon out of a line.