Results 1 to 2 of 2

Thread: Resizing Issues

  1. #1

    Default Resizing Issues

    First, is there a good source on how the resizing systems works in Qt? If I had better understood how it works I may be better able to understand my problems.

    Basically, I have a slider and want to align a label underneath. I use a spacer to move the label to underneath the slider handle. See picture.


    I overrode the resizeEvent and replaced it with the following code:

    Qt Code:
    1. void ColorMapWidget::resizeEvent(QResizeEvent *e)
    2. {
    3. Q_UNUSED(e);
    4. int val = slider->value();
    5. double spacing = slider->width() * (val / 10000.0) - (val / 10000.0) * (centerSlidingFrame->width() + 1);
    6. sliderInfoSpacer->changeSize((int)spacing, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    8. qDebug() << slider->width() << spacing;
    9. }
    To copy to clipboard, switch view to plain text mode 

    My first problem involves incorrect sizes in the resizeEvent. The output looks like:

    [Thu 10:14:56:066 0x430] INFO: 640 269.5
    [Thu 10:15:04:835 0x430] INFO: 309 134.5
    [Thu 10:15:04:867 0x430] INFO: 310 135

    Where the first value is the initial "size" after construction and the later are after I manually drag the corner of the widget to resize it. Obviously there is a large discrepancy between what it thinks the size is and what the actual size is at startup. I have a similar issue with another class where I have subclassed a QwtPlot and resize the symbols on it based on the size in the resizeEvent. The initial size is always off but subsequent resizes are correct.

    My second issues stems from updating the size of the spacer. The spacer is not being updated or redrawn (correctly) after the resizeEvent. When I reset the style sheet for the color map the spacer will resize and move to underneath the slider handle. On resizeEvents it does not update though. Am I missing something so that the spacer is actually updated? I've tried invalidating the layout and the widget, calling adjustSize(), and few others. From my understanding it should get a repaint() call right after the resizeEvent. Every other widget scales except for the spacer.


  2. #2

    Default Re: Resizing Issues

    So, I fixed the updating issue. It appears it only changes size when you invalidate the layout the QSpacerItem was added to (I was invalidating the entire widgets layout). No one has any ideas on why the initial size is so off?

Similar Threads

  1. Widget resizing issues
    By SKolaMunn in forum Newbie
    Replies: 0
    Last Post: 15th September 2011, 15:27
  2. Replies: 3
    Last Post: 2nd March 2010, 20:58
  3. QToolBar not resizing
    By vermarajeev in forum Qt Programming
    Replies: 1
    Last Post: 14th July 2007, 18:33
  4. QMdiSubWindow resizing in 4.3
    By kalpa in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2007, 13:39
  5. Automatic Resizing
    By ToddAtWSU in forum Qt Programming
    Replies: 7
    Last Post: 22nd January 2007, 18:41


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.