Results 1 to 9 of 9

Thread: user resizable and movable QLabel widget

  1. #1
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default user resizable and movable QLabel widget

    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?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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.

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    Sounds to be an easy issue...

    Is this what you intented to do
    Qt Code:
    1. class myLabel : public QLabel{
    2. public:
    3. myLabel(QWidget* parent = 0, const char* name = 0):
    4. QLabel(parent, name)
    5. {}
    6. ~myLabel(){};
    7. };
    8.  
    9. int main( int argc, char ** argv )
    10. {
    11. QApplication a( argc, argv );
    12. myLabel l;
    13. l.setCaption( "Qt Example - MyLabel" );
    14. l.show();
    15. a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    The label is moved and also can be resized

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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?

  5. #5
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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?

  7. #7
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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.

  8. #8
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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.

  9. #9
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: user resizable and movable QLabel widget

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.