Layout issues
-
@Cobra91151 Then you need more space, or smaller font, or shorter text...
Ok. So what font family do you suggest to be suitable for windows app development?
-
Ok. So what font family do you suggest to be suitable for windows app development?
@Cobra91151 Instead of lowering your font, why don't use just use your space better?
You can use 1 column for instance with separators or group boxes to denote different sections. You could use 2 columns.
One of the easiest changes that would solve your problems is getting rid of the listbox on the left and making those tabs on the top. Same effect, literally saves 25% of your horizontal space.
Also I noticed you are using addStretch now in places where I think you meant to use addSpacing. Stretch are growable blocks with a minimum size of the number you pass in. So 1 is usually plenty for a stretch, even 0 is fine (the default). If you want controllable spacing you want to use addSpacing().
-
Ok. So what font family do you suggest to be suitable for windows app development?
@Cobra91151 I will not suggest any fonts. You should use the default. You should really consider to change your layout instead of hacking around with fonts until it somehow fits.
-
This is not an option. I need three columns.
Personally, when I'm in a situation like you are, I go with a clipped Text and an info tooltip.
Here an example for a QLabel:
void setTextToLabel(QLabel *label, const QString text) { QFontMetrics metrix(label->font()); int width = label->width() - 2; QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); label->setText(clippedText); if(text == clippedText) label->setToolTip(""); else label->setToolTip(text); } -
Personally, when I'm in a situation like you are, I go with a clipped Text and an info tooltip.
Here an example for a QLabel:
void setTextToLabel(QLabel *label, const QString text) { QFontMetrics metrix(label->font()); int width = label->width() - 2; QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); label->setText(clippedText); if(text == clippedText) label->setToolTip(""); else label->setToolTip(text); }Thanks for the suggestion. I will try it and reply.
-
Personally, when I'm in a situation like you are, I go with a clipped Text and an info tooltip.
Here an example for a QLabel:
void setTextToLabel(QLabel *label, const QString text) { QFontMetrics metrix(label->font()); int width = label->width() - 2; QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); label->setText(clippedText); if(text == clippedText) label->setToolTip(""); else label->setToolTip(text); }Thanks. I have modified your function to get not only
QLabelbut allQWidgets. I post it here so others can find a solution.Code:
QString clipWidgetText(QWidget *widget, const QString widgetText, int subtractPixelSize) { QFontMetrics fontMetrics(widget->font()); int widgetWidth = widget->width() - subtractPixelSize; QString clippedText = fontMetrics.elidedText(widgetText, Qt::ElideRight, widgetWidth); return clippedText; }Usage:
QCheckBox *checkBox1 = new QCheckBox("Some long text", this) checkBox1->setText(clipWidgetText(checkBox1, checkBox1->text(), 5);Thanks to all. I have fixed all layout issues.