dtkSpacer.cpp 833 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);

Julien Wintz's avatar
Julien Wintz committed
22 23 24
    if(width && !height)
        this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    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 38 39 40 41
{
    QSize size = QWidget::sizeHint();
    if (size.width()  < 1) size.setWidth(1);
    if (size.height() < 1) size.setHeight(1);
    return(size);
}
42 43 44

//
// dtkSpacer.cpp ends here