dtkSpacer.cpp 839 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// Version: $Id$
//
//

// Commentary:
//
//

// Change Log:
//
//

// Code:
Julien Wintz's avatar
Julien Wintz committed
14

15
#include "dtkSpacer.h"
Julien Wintz's avatar
Julien Wintz committed
16 17 18

dtkSpacer::dtkSpacer(QWidget *parent, int width, int height) : QWidget(parent)
{
19
    this->setAttribute(Qt::WA_TransparentForMouseEvents, true);
Julien Wintz's avatar
Julien Wintz committed
20 21
    this->setMinimumSize(width, height);

22
    if (width && !height)
Julien Wintz's avatar
Julien Wintz committed
23
        this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
24
    else if (!width && height)
Julien Wintz's avatar
Julien Wintz committed
25
        this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Julien Wintz's avatar
Julien Wintz committed
26 27
    else
        this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Julien Wintz's avatar
Julien Wintz committed
28 29 30 31 32 33 34
}

dtkSpacer::~dtkSpacer(void)
{

}

35
QSize dtkSpacer::sizeHint(void) const
Julien Wintz's avatar
Julien Wintz committed
36 37
{
    QSize size = QWidget::sizeHint();
38

Julien Wintz's avatar
Julien Wintz committed
39
    if (size.width()  < 1) size.setWidth(1);
40

Julien Wintz's avatar
Julien Wintz committed
41
    if (size.height() < 1) size.setHeight(1);
42 43

    return (size);
Julien Wintz's avatar
Julien Wintz committed
44
}
45 46 47

//
// dtkSpacer.cpp ends here