PDA

View Full Version : Widget is not so smooth when resizing?



MorrisLiang
10th May 2010, 18:25
I'm not sure if I can fully expain what is this question,but please read on.

Here,I'm creating a frameless window.


MyWindow::MyWindow(QWidget *parent) :
QMainWindow(parent)
{
ui.setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_NoMousePropagation);
resizeHandle = new ResizeHandle(this);
resizeHandle->setCursor(Qt::SizeVerCursor);
...
connect(resizeHandle, SIGNAL(sizeChanged(QPoint&)), this, SLOT(rearrange(QPoint&)));
}

http://i960.photobucket.com/albums/ae82/liangmorr/normal.png
At the bottom,there's the resizeHandle.When I press on it,I can drag it.Then it will emit sizeChanged(QPoint&) signal,indicating how much I drag(usually 1 to 3 pixel per SIGNAL).Then I resize MyWindow in rearrange(QPoint&):


void MyWindow::rearrange(QPoint& newSize)
{
int newH = newSize.ry();

resize(this->width(), this->height() + newH);
QFrame* footer = ui.footerFrame;
footer->setGeometry(footer->x(), footer->y() + newH, footer->width(), footer->height());
....
}

Here is what it looks like when I resizing:
http://i960.photobucket.com/albums/ae82/liangmorr/resizing.png
Seems like a glitch.It's not always this dramatic,but it appears even when I'm dragging slowly.Anyway,it's all about the effect.
Maybe I'm missing something when I implement such kind of function.Should I use so-called double-buffer or something,and how?

squidge
10th May 2010, 20:45
Have you tried this in release mode instead of debug? I'm noticed a few things are a bit jerky in debug mode, probably because of the unoptimised code and lots more validation.

MorrisLiang
11th May 2010, 01:44
Ok,I will try that.

This problem is gone when I build release.
Thanks~:o