Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Split QStatusBar and choose where to display QStatusTips
Qt 6.11 is out! See what's new in the release blog

Split QStatusBar and choose where to display QStatusTips

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.5k Views
  • 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.
  • A Offline
    A Offline
    Ailurus
    wrote on last edited by Ailurus
    #1

    I'm wondering how to split the QStatusBar in my QMainWindow into two equal parts and to subsequently show QStatusTips in either the left or the right part.

    Perhaps this approach is a step in the right direction —

    1.) Create two QLabels*,

    labelStatusTip = new QLabel("");
    labelGeneralInfo = new QLabel("Initial text");
    

    2.) Add them to the QStatusBar, setting stretch to 1 results in two equal parts (same widths)

    ui->statusBar->addPermanentWidget(labelStatusTip, 1);
    ui->statusBar->addPermanentWidget(labelGeneralInfo, 1);
    

    3.) Now, how do I set the text of labelStatusTip to the actual QStatusTips? Do I have to define a custom QStatusBar and override the showMessage() and clearMessage() slots (see http://doc.qt.io/qt-5/qstatusbar.html)?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Ailurus
      wrote on last edited by Ailurus
      #2

      Hmm, this works —

      connect(ui->statusBar, SIGNAL(messageChanged(QString)), this, SLOT(showStatusTip()));
      
      ...
      
      void MyMainWindow::showStatusTip() {
        labelStatusTip->setText(ui->statusBar->currentMessage());
      }
      
      1 Reply Last reply
      1
      • B Offline
        B Offline
        bpfel
        wrote on last edited by
        #3

        Hi Ailurus,

        I am really new to QT and currently working with the Python bindings.

        Would you know how to implement your solution when using pyhton?

        I am struggling with extracting the right signal for the job...

        Best,

        bpfel

        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 Extensions
        • Unsolved