anirbanjoy
28th March 2011, 11:56
Hi,
I have an applciation with a simple status bar.
6163
The issue is whenever I resize the main window, the texts in the status bar are overlapping with each other.
6164
I want them to be a nicely cropped like any native windows application (e.g. Windows Word). Any idea on how to achieve that?
Following code shows how I initialize the text in this status bar.
void SSDMainWindow::createStatusBar()
{
statusLabel = new QLabel(tr("Ready"));
statusLabel->setIndent(3);
statusBar()->addWidget(statusLabel);
gridSpacingLabel = new QLabel(tr(" Grid Spacing: "));
gridSpacingLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
gridSpacingLabel->setMinimumSize(gridSpacingLabel->sizeHint());
statusBar()->addPermanentWidget(gridSpacingLabel);
//statusBar()->addWidget(gridSpacingLabel);
gridSpacingLabel->setText(tr(" Grid Spacing:"));
xPosLabel = new QLabel(tr(" X: 640 "));
xPosLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
xPosLabel->setMinimumSize(xPosLabel->sizeHint());
statusBar()->addPermanentWidget(xPosLabel);
// statusBar()->addWidget(xPosLabel);
xPosLabel->setText(tr(" X:"));
yPosLabel = new QLabel(tr(" Y: 480 "));
yPosLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
yPosLabel->setMinimumSize(yPosLabel->sizeHint());
statusBar()->addPermanentWidget(yPosLabel);
// statusBar()->addWidget(yPosLabel);
yPosLabel->setText(tr(" Y:"));
widthLabel = new QLabel(tr(" Width: 640 "));
widthLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
widthLabel->setMinimumSize(widthLabel->sizeHint());
statusBar()->addPermanentWidget(widthLabel);
// statusBar()->addWidget(widthLabel);
widthLabel->setText(tr(" Width:"));
heightLabel = new QLabel(tr(" Height: 480 "));
heightLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
heightLabel->setMinimumSize(heightLabel->sizeHint());
statusBar()->addPermanentWidget(heightLabel);
// statusBar()->addWidget(heightLabel);
heightLabel->setText(tr(" Height:"));
unsavedDataLabel = new QLabel();
QPixmap pixmap(":changes.png");
unsavedDataLabel->setPixmap(pixmap);
unsavedDataLabel->setMinimumSize(unsavedDataLabel->sizeHint());
statusBar()->addPermanentWidget(unsavedDataLabel);
// statusBar()->addWidget(unsavedDataLabel);
unsavedDataLabel->clear();
if (statusBarManager) {
statusBarManager->connectUnsavedData(this, SLOT(unsavedData(bool)));
statusBarManager->connectPositionChanged(this, SLOT(positionChanged(qreal, qreal)));
statusBarManager->connectSizeChanged(this, SLOT(sizeChanged(qreal, qreal)));
statusBarManager->connectGridSpacingChanged(this, SLOT(gridSpacingChanged(int)));
}
}
Regards,
Anirban
I have an applciation with a simple status bar.
6163
The issue is whenever I resize the main window, the texts in the status bar are overlapping with each other.
6164
I want them to be a nicely cropped like any native windows application (e.g. Windows Word). Any idea on how to achieve that?
Following code shows how I initialize the text in this status bar.
void SSDMainWindow::createStatusBar()
{
statusLabel = new QLabel(tr("Ready"));
statusLabel->setIndent(3);
statusBar()->addWidget(statusLabel);
gridSpacingLabel = new QLabel(tr(" Grid Spacing: "));
gridSpacingLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
gridSpacingLabel->setMinimumSize(gridSpacingLabel->sizeHint());
statusBar()->addPermanentWidget(gridSpacingLabel);
//statusBar()->addWidget(gridSpacingLabel);
gridSpacingLabel->setText(tr(" Grid Spacing:"));
xPosLabel = new QLabel(tr(" X: 640 "));
xPosLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
xPosLabel->setMinimumSize(xPosLabel->sizeHint());
statusBar()->addPermanentWidget(xPosLabel);
// statusBar()->addWidget(xPosLabel);
xPosLabel->setText(tr(" X:"));
yPosLabel = new QLabel(tr(" Y: 480 "));
yPosLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
yPosLabel->setMinimumSize(yPosLabel->sizeHint());
statusBar()->addPermanentWidget(yPosLabel);
// statusBar()->addWidget(yPosLabel);
yPosLabel->setText(tr(" Y:"));
widthLabel = new QLabel(tr(" Width: 640 "));
widthLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
widthLabel->setMinimumSize(widthLabel->sizeHint());
statusBar()->addPermanentWidget(widthLabel);
// statusBar()->addWidget(widthLabel);
widthLabel->setText(tr(" Width:"));
heightLabel = new QLabel(tr(" Height: 480 "));
heightLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
heightLabel->setMinimumSize(heightLabel->sizeHint());
statusBar()->addPermanentWidget(heightLabel);
// statusBar()->addWidget(heightLabel);
heightLabel->setText(tr(" Height:"));
unsavedDataLabel = new QLabel();
QPixmap pixmap(":changes.png");
unsavedDataLabel->setPixmap(pixmap);
unsavedDataLabel->setMinimumSize(unsavedDataLabel->sizeHint());
statusBar()->addPermanentWidget(unsavedDataLabel);
// statusBar()->addWidget(unsavedDataLabel);
unsavedDataLabel->clear();
if (statusBarManager) {
statusBarManager->connectUnsavedData(this, SLOT(unsavedData(bool)));
statusBarManager->connectPositionChanged(this, SLOT(positionChanged(qreal, qreal)));
statusBarManager->connectSizeChanged(this, SLOT(sizeChanged(qreal, qreal)));
statusBarManager->connectGridSpacingChanged(this, SLOT(gridSpacingChanged(int)));
}
}
Regards,
Anirban