PDA

View Full Version : QMainWindow and setContentsMargins



themolecule
7th February 2010, 20:03
I'm trying to create an application that has a single QGraphicsView in the center.

The QGraphicsView is the centralWidget.

I can't seem to get rid of the margin/padding around it in the QMainWindow.

I'm trying to do

layout()->setContentsMargins(0,0,0,0)

on the QMainWindow, but it doesn't seem to have an effect. Actually, setting to values greater than zero makes the margin bigger, but setting to zero does not make it go away.

if I read out the initial margin I get 20, but setting to zero doesn't do anything.


mMainWindow::mMainWindow(QWidget *parent) : QMainWindow(parent)
{
ui.setupUi(this);

int l,r,t,b;

layout()->getContentsMargins(&l,&r,&t,&b);

std::cout << l << " " << r << " " << t << " " << b <<"\n";

layout()->setContentsMargins(0,0,0,0);

this->getContentsMargins(&l,&r,&t,&b);

std::cout << l << " " << r << " " << t << " " << b <<"\n";

connect(ui.actionFull_Screen, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
}

What am I doing wrong?