PDA

View Full Version : user resizable and movable QLabel widget



hvengel
2nd April 2007, 04:25
I need to have an rectangular area where I paint colors that will be read by a colormeter or spectrophotometer. I would like to allow users to resize and/or move this widget inside the applications workspace (this will be most of the screen) so that they can place the meter were ever it works best for them.

Currently I am using a QLabel that is a fixed size and is always in the middle of the dialog as the area that displays the pixmap that contains the color I want displayed. This can not be resized or moved as far as I know. But I could be wrong about this.

Looking at the QT docs I thought that perhaps I could make a QFrame that is in this main area of the dialog a QWorkspace and then make the QLabel child widget of the QWorkspace. Something like this:

// MDIframe was created in designer
QWorkspace* colorPatchWS = new QWorkspace(MDIframe);
QLabel* pixmapColor = new QLabel(pixmapColor);
pixmapColor -> setMinimumSize(QSize(400,400));

But when I test the resulting app it appears that the QWorkspace is only in the very upper left hand part of the QFrame. I don't care how I solve the issue. So I don't care if QWorkspace will work or not or if there is some other better solution. I just need a solution that works. ANyone have any ideas?

marcel
2nd April 2007, 05:06
You cannot move the label because of the layout of the dialog.

Try implementing a custom layout for the dialog and move the label in mouseMoveEvent.
The custom layout should be something simple (you could look at the Flow layout in the Qt demos ), something to allow you to drag you label around.

vermarajeev
2nd April 2007, 07:22
Sounds to be an easy issue...

Is this what you intented to do

class myLabel : public QLabel{
public:
myLabel(QWidget* parent = 0, const char* name = 0):
QLabel(parent, name)
{}
~myLabel(){};
};

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
myLabel l;
l.setCaption( "Qt Example - MyLabel" );
l.show();
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
return a.exec();
}
The label is moved and also can be resized

marcel
2nd April 2007, 07:34
Do you want to move this with the mouse inside the bounds of a dialog or a MDI child?
Or do you want a MDI window that is exactly the size of the QLabel?

hvengel
10th April 2007, 00:25
I need an area where I can place a pixmap so that I can control the color of the pixmap. This will be in a larger dialog that will take over the display. The user needs to be able to move and resize the widget containing the pixmap. This area will be used to take measurements of the display for calibration and profiling using either a color meter or a spectrophotometer.

I currently have a set of sliders that can be used to position and resize the label and it's pixmap in the larger dialog. This works OK but it would be better (more intuitive) if the user could just drag and resize this with a mouse like they can with a dialog. I was originally thinking this would be simple and perhaps it is but I have not found a simple way to do it. Maybe there is a better type of widget than a label for this that has built in dragability and resizability? I am totally open to suggestions on how to improve this even though I have an OK solution.

If you would like to have a look at what I have you can download the CVS version from sourceforge here http://sourceforge.net/projects/lprof/ and have a look. This builds fine on Linux but has been rapidly changing lately and may have trouble building on your specific installation. It should work with the following measurement devices:

X-Rite/GretagMacbeth EyeOne Display (all models)
X-Rite/GretagMacbeth EyeOne Pro
X-Rite DPT-92
X-Rite DPT-94
GretagMacbeth Spectrolino

But at this point it has only been tested with the EyeOne Display LT.

In a few days I should have a Windows VS 2005 build working as well. The current release will build and run on a Mac but CVS needs some Mac porting done before this will run there. The Mac built likely also needs to have some work done at this point.

In any case you can pull up the dialog in question without having a meter installed to see how it currently works. From the main dialog select the Monitor Profiler tab. Then select the "I want to build an accurate profile from measurements" radio button and then the "Create files" radio button and then the "Calibrate and Measure". This will take you to a dialog that controls what type of measurement is being taken and other parameters related to these measurements. Clicking the Measure button will take you to the dialog in question.

marcel
10th April 2007, 00:59
Hey, I have a non-Qt question...
What library do you use for profile generation and for the CMM? Or did you made these yourself?

hvengel
10th April 2007, 01:16
LProf links LCMS and also some parts of ArgyllCMS but much of the profiling code is specific to LProf. When LProf displays a proof in the camera/scanner profiler it uses LCMS to do the transform. The instrument support code and some of the regression analysis code is from ArgyllCMS. LProf also uses LCMS to generate the basic profile object and to do basic profile manipulations like adding tags and tag data like CLUT tables and measurement data.

hickscorp
10th April 2007, 11:33
Hello vermarajeev,

Since i'm not very good at QT, here is what i would have done (If i understand well what you want):
In your main dialog constructor, create the label as described in the previous answer. Then use the set window attribute method to not show the label in the taskbar / dock / applet bar.
Your label can be a reimplementation of QLabel, with drag / resize event handled by your own code.
But when the user attempts to move / resize the label, you have to do a colision check with your main window, so it never goes out of it...
You will probably come to the focus issue, which will bring your main window on top of the label when clicked... But it can be fixed too.

It's ugly :) But the user will actually "see" a widget on top of his window, which is moveable and dragable :)

The other solution can be to use a QDockWidget, it's very handly and can be docked, moved, sized...

Pierre.

hvengel
12th April 2007, 00:01
I think QDockWidget is Qt 4 only. At least I couldn't find it in the Qt3 class reference docs. My project is Qt 3.

vermarajeev - No that is not what I want. I want a dialog that has an area contained in it that can have a pixmap painted on it and that can be moved and resize inside the parent dialog. Sounds simple enough but none of the replies have a good solution.