Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, February 2008
What is difference among QPicture, QPixmap and QImage


Message 1 in thread

All three are image buffers and paintable with QPainter.. what is
difference?

I can find so may usage documents. but I could not find any document with

comparison (especially how different in systematic implementation) 

Is there any specification or documentation?

 

One more discussion. 

are there quite benefits when we use QGraphicsScene instead of QWidget or
QGLWidget?

Is there any benchmarking report or document?

 

Samuel B. Park  (byeongjun.park@xxxxxxxx) - Research Associate of Sohn
Laboratory.

Case Western Reserve University. School of Medicine. Dept. Rad. Oncology

http://rophys.meds.case.edu

 


Message 2 in thread

If you look at the code for QPixmap and QImage, you will see that for 24-bit
bitmaps under Windows, they share the same image data format. Copying from
one to the other just copies the pointer reference. So for 24-bit bitmaps
under Windows, which class you choose is arbitrary in terms of performance.
I do not know what the situation is for the Mac and Linux versions.

 

..tony.. 

 

From: Samuel Byeongjun Park [mailto:Byeongjun.Park@xxxxxxxx] 
Sent: Wednesday, February 13, 2008 12:50 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: What is difference among QPicture, QPixmap and QImage

 

All three are image buffers and paintable with QPainter.. what is
difference?

I can find so may usage documents. but I could not find any document with

comparison (especially how different in systematic implementation) 

Is there any specification or documentation?

 

One more discussion. 

are there quite benefits when we use QGraphicsScene instead of QWidget or
QGLWidget?

Is there any benchmarking report or document?

 

Samuel B. Park  (byeongjun.park@xxxxxxxx) - Research Associate of Sohn
Laboratory.

Case Western Reserve University. School of Medicine. Dept. Rad. Oncology

http://rophys.meds.case.edu

 


Message 3 in thread

From the first paragraph of QImage's (and QPixmap's) documentation:

"Qt provides four classes for handling image data: QImage, QPixmap, QBitmap
and QPicture. QImage is designed and optimized for I/O, and for direct pixel
access and manipulation, while QPixmap is designed and optimized for showing
images on screen. QBitmap is only a convenience class that inherits QPixmap,
ensuring a depth of 1. Finally, the QPicture class is a paint device that
records and replays QPainter commands."

Tom

On Feb 13, 2008 3:50 PM, Samuel Byeongjun Park <Byeongjun.Park@xxxxxxxx>
wrote:

>  All three are image buffers and paintable with QPainter.… what is
> difference?
>
> I can find so may usage documents… but I could not find any document with
>
> comparison (especially how different in systematic implementation)
>
> Is there any specification or documentation?
>
>
>
> One more discussion…
>
> are there quite benefits when we use QGraphicsScene instead of QWidget or
> QGLWidget?
>
> Is there any benchmarking report or document?
>
>
>
> Samuel B. Park  (byeongjun.park@xxxxxxxx) - Research Associate of Sohn
> Laboratory.
>
> Case Western Reserve University. School of Medicine. Dept. Rad. Oncology
>
> http://rophys.meds.case.edu
>
>
>

Message 4 in thread

Thank you Tom.

However, I am still curious?

 

For example?.

I used 5 QImage(about 800x600 size) objects to draw overlayed image on
QWidget.

QImage are prepared (with multiple painting commands -let?s say hundred
drawPoint(), actually more- before paintEvent() of QWidget, independently.

paintEvent() only drawed the QImages with change of QImage.

 

Which one is faster? 

For QImage, it takes time to transport QImage to Framebuffer.

ð  This made some delay in paintEvent()

On the contrary For QPixmap, it takes time to send painting commands?

ð  This made some delay when the user changes some painting items.

 

When I tried QGLWidget with QImage, it was slower than QWidget.

Can anybody explain me why?

 

Is there any difference between these and QPicture?

Do you think QPicture + QGraphicScene can be faster?

 

Thanks ?.

 

Sam

 

From: Tom Panning [mailto:lurchvt@xxxxxxxxx] 
Sent: Wednesday, February 13, 2008 3:56 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: What is difference among QPicture, QPixmap and QImage

 

From the first paragraph of QImage's (and QPixmap's) documentation:

"Qt provides four classes for handling image data: QImage, QPixmap, QBitmap
and QPicture. QImage is designed and optimized for I/O, and for direct pixel
access and manipulation, while QPixmap is designed and optimized for showing
images on screen. QBitmap is only a convenience class that inherits QPixmap,
ensuring a depth of 1. Finally, the QPicture class is a paint device that
records and replays QPainter commands."

Tom

On Feb 13, 2008 3:50 PM, Samuel Byeongjun Park <Byeongjun.Park@xxxxxxxx>
wrote:

All three are image buffers and paintable with QPainter.? what is
difference?

I can find so may usage documents? but I could not find any document with

comparison (especially how different in systematic implementation) 

Is there any specification or documentation?

 

One more discussion? 

are there quite benefits when we use QGraphicsScene instead of QWidget or
QGLWidget?

Is there any benchmarking report or document?

 

Samuel B. Park  (byeongjun.park@xxxxxxxx) - Research Associate of Sohn
Laboratory.

Case Western Reserve University. School of Medicine. Dept. Rad. Oncology

http://rophys.meds.case.edu

 

 


Message 5 in thread

Hello all...

 

I have been trying to put a QProgressBar as a Delegate in a column in my
QTableView. 

This widget is not an editor, so the createEditor method has no interest for
me.

I have been homing in to the paint method. As firt argument it gets a
qpainter and that is good... 

Now the sticky problem is... all the examples I have found show a
textDocument that happen to have a drawContents method that has as argument
a qpainter.

The problem for me is that the QProgressBar doesn't have any method that
take a qpainter as argument...

 

I tried an alternative route, getting the device from the painter and then
trying to use the render method on the qprogressbar. It does show the
progressbar, but doesn't get any information about the cell size where it is
supposed to draw. Moreover, I get messages at the prompt about the painter
not being active.

The painter I get the device from is active.

 

So now I'm at loss... any help for both position/size and setting up the
device correctly?

 

Thanks in advance

Stefano

 

 


Message 6 in thread

Stefano Tursi wrote:
 

	I have been trying to put a QProgressBar as a Delegate in a
column in my QTableView. 

	This widget is not an editor, so the createEditor method has no
interest for me.

	I have been homing in to the paint method. As firt argument it
gets a qpainter and that is good...  

 Take a look at QStyle::drawControl.  You use this in the paint method
for your delegate.  Create a QStyleOptionProgressBar object and copy the
elements of the QStyleOptionViewItem into it.  Then, set the elements
relevant to your progress bar.  Call drawControl with
QStyle::CE_ProgressBar, the painter passed into the paint function and
the QStyleOptionProgressBar object address.

 

You may also need to override the sizeHint on your delegate.  You can
call QStyle::sizeFromContents you can use QStyle::pixelMetric and
PM_ProgressBarChunkWidth as a starting point.

 

I have not done this with a progress bar, but I have done it with other
controls.  It took a bit of experimentation to get the first time, but
is should work after only a small amount of frustration.

 

Good luck,

Rob


Message 7 in thread

Thanks a lot!

Got good results... only thing still not working is the text. The control
show up well, it leaves the space for the text on the right of the progress
bar, but no text appear.

 

Here is the code I wrote (it is in python, but it doesn't change much from
c++)

 

    def paint(self, painter, option, index):

        p = int(index.model().data(index).toDouble()[0]*100)

        psb=QtGui.QStyleOptionProgressBarV2()

        psb.rect=option.rect

        psb.direction=option.direction

        psb.palette=option.palette

        psb.fontMetrics=option.fontMetrics

        psb.maximum=100

        psb.minimum=0

        psb.progress=p

        psb.textVisible=True 

        st=QtGui.QApplication.style()

        painter.save()

        st.drawControl(QtGui.QStyle.CE_ProgressBar,psb,painter) 

        painter.restore()

 

I did try to see if changing the text colour did any good:

psb.palette.setColor(QtGui.QPalette.Text,QtGui.QColor(QtCore.Qt.blue))

but I can see no difference.

By the way, does anybody know a way to put the text in the progressbar
instead of on the right side?

        

Cheers

Stefano

 

From: Bachrach, Robert L [mailto:rob.bachrach@xxxxxxxxxxxxxxxxxxx] 
Sent: 14 February 2008 12:18
To: stefano.tursi@xxxxxxxxx; qt-interest@xxxxxxxxxxxxx
Subject: RE: Delegating to a widget in a QtableView

 

Stefano Tursi wrote:

 

I have been trying to put a QProgressBar as a Delegate in a column in my
QTableView. 

This widget is not an editor, so the createEditor method has no interest for
me.

I have been homing in to the paint method. As firt argument it gets a
qpainter and that is good...  

 Take a look at QStyle::drawControl.  You use this in the paint method for
your delegate.  Create a QStyleOptionProgressBar object and copy the
elements of the QStyleOptionViewItem into it.  Then, set the elements
relevant to your progress bar.  Call drawControl with
QStyle::CE_ProgressBar, the painter passed into the paint function and the
QStyleOptionProgressBar object address.

 

You may also need to override the sizeHint on your delegate.  You can call
QStyle::sizeFromContents you can use QStyle::pixelMetric and
PM_ProgressBarChunkWidth as a starting point.

 

I have not done this with a progress bar, but I have done it with other
controls.  It took a bit of experimentation to get the first time, but is
should work after only a small amount of frustration.

 

Good luck,

Rob


Message 8 in thread

Oooops...

No text will ever show... if I forget to set the text attribute... the most
obvious thing is the last I look for...

    def paint(self, painter, option, index):

        p = int(index.model().data(index).toDouble()[0]*100)

        psb=QtGui.QStyleOptionProgressBarV2()

        psb.rect=option.rect

        psb.direction=option.direction

        psb.palette=option.palette

        psb.fontMetrics=option.fontMetrics

 
psb.palette.setColor(QtGui.QPalette.Text,QtGui.QColor(QtCore.Qt.blue))

        psb.maximum=100

        psb.minimum=0

        psb.progress=p

        psb.text="%d%%"%p

        psb.textVisible=True 

        st=QtGui.QApplication.style()

        painter.save()

        st.drawControl(QtGui.QStyle.CE_ProgressBar,psb,painter) 

        painter.restore()

 

From: stefano tursi [mailto:stefano.tursi@xxxxxxxxx] 
Sent: 14 February 2008 23:17
To: 'Bachrach, Robert L'; 'qt-interest@xxxxxxxxxxxxx'
Subject: RE: Delegating to a widget in a QtableView

 

Thanks a lot!

Got good results... only thing still not working is the text. The control
show up well, it leaves the space for the text on the right of the progress
bar, but no text appear.

 

Here is the code I wrote (it is in python, but it doesn't change much from
c++)

 

    def paint(self, painter, option, index):

        p = int(index.model().data(index).toDouble()[0]*100)

        psb=QtGui.QStyleOptionProgressBarV2()

        psb.rect=option.rect

        psb.direction=option.direction

        psb.palette=option.palette

        psb.fontMetrics=option.fontMetrics

        psb.maximum=100

        psb.minimum=0

        psb.progress=p

        psb.textVisible=True 

        st=QtGui.QApplication.style()

        painter.save()

        st.drawControl(QtGui.QStyle.CE_ProgressBar,psb,painter) 

        painter.restore()

 

I did try to see if changing the text colour did any good:

psb.palette.setColor(QtGui.QPalette.Text,QtGui.QColor(QtCore.Qt.blue))

but I can see no difference.

By the way, does anybody know a way to put the text in the progressbar
instead of on the right side?

        

Cheers

Stefano

 

From: Bachrach, Robert L [mailto:rob.bachrach@xxxxxxxxxxxxxxxxxxx] 
Sent: 14 February 2008 12:18
To: stefano.tursi@xxxxxxxxx; qt-interest@xxxxxxxxxxxxx
Subject: RE: Delegating to a widget in a QtableView

 

Stefano Tursi wrote:

 

I have been trying to put a QProgressBar as a Delegate in a column in my
QTableView. 

This widget is not an editor, so the createEditor method has no interest for
me.

I have been homing in to the paint method. As firt argument it gets a
qpainter and that is good...  

 Take a look at QStyle::drawControl.  You use this in the paint method for
your delegate.  Create a QStyleOptionProgressBar object and copy the
elements of the QStyleOptionViewItem into it.  Then, set the elements
relevant to your progress bar.  Call drawControl with
QStyle::CE_ProgressBar, the painter passed into the paint function and the
QStyleOptionProgressBar object address.

 

You may also need to override the sizeHint on your delegate.  You can call
QStyle::sizeFromContents you can use QStyle::pixelMetric and
PM_ProgressBarChunkWidth as a starting point.

 

I have not done this with a progress bar, but I have done it with other
controls.  It took a bit of experimentation to get the first time, but is
should work after only a small amount of frustration.

 

Good luck,

Rob