Thank you. Ill post again when I get stuck or confused again.
Thank you. Ill post again when I get stuck or confused again.
You're welcome...
Just one thing: the signal I mentioned earlier should be emitted from the label's mousePressEvent.
Hello again.
I subclassed QLabel and got to the point where I assign the position of the mouse event to a QPoint. Now, I understand that I need to use this QPoint to get the QRgb value of whatever is underneath. Question, how do I do this?
Here you should use the pixmap() property of QLabel to get the QRgb at the position where the mouse was clicked inside the label.
Oh, yes... Forgot all about that. QPixmap doesn't expose pixel data. You could convert it to a QImage, although this adds a bit of extra overhead:
You could create a member QImage so you don't have to convert the pixmap at every mouse click.Qt Code:
.... later, in mousePressEvent QRgb color = img.pixel(mouseX, mouseY);To copy to clipboard, switch view to plain text mode
See QImage::pixel
QPixmap::toImage and QLabel::pixmap()
Ok Ill give it a go thanks.
Marcel, Id like to put in a few more questions if you dont mind. If my custom frame is on a dialog, whats the easiest way to return to Main Window to pick a color then return again to the dialog to display the color? I understand that the dialog should be modeless..
Yes, the dialog should be modeless, otherwise you couldn't interact with the main window. You could set the flags of the dialog to be Qt::Tool. This is usually done for palette windows, like in Photshop and Visual Studio.
Once you select a color in the main window you could transmit it to the dialog via a signal. The signal should be emitted by the main window itself or by an object the main window contains.
In order to add a custom slot to the dialog you will have to subclass it.
ramstormrage (4th May 2008)
Alright! Im learning new stuff..
Ok thanks again, youve been a great help.
no problem
Bookmarks