29 mLayout =
new QHBoxLayout();
30 mLayout->setContentsMargins( 2, 0, 2, 0 );
31 mLayout->setSpacing( 6 );
33 mLineEdit =
new QLineEdit( QString() );
34 mLineEdit->setDisabled(
true );
35 mLineEdit->setFrame(
false );
36 mLineEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
37 QPalette palette = mLineEdit->palette();
38 palette.setColor( QPalette::Disabled, QPalette::Text, QPalette::WindowText );
39 mLineEdit->setPalette( palette );
40 mLineEdit->setStyleSheet( QStringLiteral(
"* { border: 0; background-color: rgba(0, 0, 0, 0); }" ) );
41 mLayout->addWidget( mLineEdit, 10 );
50 mLayout->insertWidget( 0, widget, stretch, Qt::AlignLeft );
54 mLayout->addWidget( widget, stretch, Qt::AlignLeft );
61 mLayout->removeWidget( widget );
66 return mLineEdit->text();
71 mLineEdit->setText( text );
72 mLineEdit->setCursorPosition( 0 );
75 if ( !mTempMessageTimer )
77 mTempMessageTimer =
new QTimer(
this );
79 mTempMessageTimer->setSingleShot(
true );
81 mTempMessageTimer->start( timeout );
83 else if ( mTempMessageTimer )
85 delete mTempMessageTimer;
86 mTempMessageTimer =
nullptr;
92 mLineEdit->setText( QString() );
97 if ( mParentStatusBar )
98 QStatusBar::disconnect( mShowMessageConnection );
100 mParentStatusBar = statusBar;
102 if ( mParentStatusBar )
103 mShowMessageConnection = connect( mParentStatusBar, &QStatusBar::messageChanged,
this, [
this](
const QString & message ) {
showMessage( message ); } );
108 QWidget::changeEvent( event );
110 if ( event->type() == QEvent::FontChange )
112 mLineEdit->setFont( font() );
Anchor
Placement anchor for widgets.
@ AnchorLeft
Anchor widget to left of status bar.
@ AnchorRight
Anchor widget to right of status bar.
void clearMessage()
Removes any temporary message being shown.
void removeWidget(QWidget *widget)
Removes a widget from the status bar.
QgsStatusBar(QWidget *parent=nullptr)
Constructor for QgsStatusBar.
void changeEvent(QEvent *event) override
void addPermanentWidget(QWidget *widget, int stretch=0, Anchor anchor=AnchorRight)
Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a ch...
QString currentMessage() const
Returns the current message shown in the status bar.
void setParentStatusBar(QStatusBar *statusBar)
Sets the parent status bar.
void showMessage(const QString &message, int timeout=0)
Displays the given message for the specified number of milli-seconds (timeout).