Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOMEHOW SOLVED] QStatusBar - draw frameless widgets
Qt 6.12 LTS is out! See what's new in the release blog

[SOMEHOW SOLVED] QStatusBar - draw frameless widgets

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello everybody,
    I'm painting my own widget on status bar and have some trouble with it.

    On windows, status bar draws two small lines on the right of my widget, one horizontal and one vertical:
    !http://vip2006.net/statusbar.png(StatusBar Windows)!

    And on Linux system, same code draws a border around the widget:
    !http://vip2006.net/statusbarlin.png(StatusBar Linux)!

    How do I get them off?

    My widget is subclass of QWidget:
    @
    class ExStatusText : public QWidget
    {
    Q_OBJECT

    public:
    ExStatusText(QWidget *parent = NULL);
    void SetText(const QString & text);

    protected:
    void paintEvent(QPaintEvent *);

    private:
    QStaticText m_staticText;
    QPixmap clock;
    };

    ExStatusText::ExStatusText(QWidget *parent):QWidget(parent),clock(":/TecArtStarter/Resources/clock.png")
    {

    }

    void ExStatusText::SetText(const QString & text)
    {
    this->m_staticText.setText(text);
    QTimer::singleShot(1,this,SLOT(update()));
    }

    void ExStatusText::paintEvent(QPaintEvent *)
    {
    QPainter painter(this);
    painter.drawPixmap(0,0,this->clock);
    painter.drawStaticText(this->clock.width()+5,0,this->m_staticText);
    }

    //here is how I'm adding it to the QStatusBar
    this->crmtime = new ExStatusText();
    this->ui.statusBar->addWidget(this->crmtime,1);
    @

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You can try to set style sheet to border: none, or, if you have available option, you can try to set frameShape to NoFrame.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        have tried this allready... doesn't help... looks like I must subclass QStatusBar and reimplement its paintEvent...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved