0

I am trying to insert a very tiny QLabel into a very tiny QFrame.

The QFrame is used as a spacer and I thought it a perfect place to add text.

In code that text would change (in to mm). Because mm is so giant it is clipped...

Yet it seems to me it would fit if I could just get rid of the margins !

enter image description here

So I try:

ui->tinyFrame is created in Designer... it has geometry 0,0,10,10

QLabel* unitLabel  = new QLabel("mm");
unitLabel->setFixedSize(8,8);
unitLabel->setFont(QFont("Arial Narrow", 7));
unitLabel->setMargin(0);
unitLabel->setContentsMargins(0,0,0,0);

QHBoxLayout* unitLayout = new QHBoxLayout();
unitLayout->setSpacing(0);    // I try everything
unitLayout->setMargin(0);
unitLayout->setContentsMargins(0,0,0,0);
ui->tinyFrame->setLayout(unitLayout);
ui->tinyFrame->setContentsMargins(0,0,0,0);
unitLayout->addWidget(unitLabel);

What else can I try to remove the space around my little label ?

1 Answer 1

1

I am trying to insert a very tiny QLabel into a very tiny QFrame. What can I try to remove the space around my little label?

QLabel is derived from QFrame: maybe you can just replace that QFrame with QLabel then? And no nested layout for that frame.

... as long as you tried layout->setSpacing(0) already...

1
  • I tried - the text is still clipped. But for some reason the left margin disappeared. I ended up just giving it a bigger size - and the size didn't increase, the text was not clipped anymore... I don't understand but it worked
    – Thalia
    Commented Mar 31, 2016 at 22:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.