Results 1 to 4 of 4

Thread: Status Bar

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Status Bar

    Is it possible to pass a value to the status bar in the main window with a signal/slot? From a dialog? I'm having trouble figuring out the right code.
    Any suggestions or pointers to examples?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Status Bar

    What kind of value? What do you want to do with it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Status Bar

    Thanks Wysota. I have a function that updates a QString/varchar database field.
    When that changes, I want to display the new value in the status bar as a permanent message preceded by some text. The text appears ok, but when I try code to pass the value, I can't get a compile. Just my lack of Qt knowledge, but I can't seem to find any references to doing this. Can't find anything in my books or online.
    Here are some code snippets of what I tried:

    Qt Code:
    1. class ControlDB:public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. ControlDB(QObject *parent = 0);
    7. void makeControlDB();
    8. void setLastLog(QString);
    9. void setOper(QString);
    10. QString getLastLog();
    11. QString getOper();
    12.  
    13. signals:
    14. void valueChanged(QString newValue);
    15. }
    16.  
    17. //cpp file
    18. ControlDB::ControlDB(QObject *parent)
    19. {
    20.  
    21. }
    22. void ControlDB::setOper(QString oper) {
    23. //some code to change the oper value
    24. emit valueChanged(oper);
    25. }
    26.  
    27. MainWindow::MainWindow(QWidget *parent)
    28. : QMainWindow(parent), ui(new Ui::MainWindow)
    29. {
    30. ui->setupUi(this);
    31. setupActions();
    32.  
    33. mStatLabel = new QLabel;
    34. statusBar()->addPermanentWidget(mStatLabel);
    35. ControlDB ctrl;
    36. connect(&ctrl, SIGNAL(valueChanged(QString)), this, SLOT(updateStats(QString)));
    37. updateStats(QString);
    38. }
    39.  
    40. void MainWindow::updateStats(oper)
    41. {
    42. QString operOutput = "Current op is " + oper;
    43. mStatLabel->setText(operOutput);
    44. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for any assistance.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Status Bar

    What is the error you get?

    Line #37 of the code above is surely incorrect. It should probably say:
    Qt Code:
    1. updateStats(QString());
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. collect2: ld returned 1 exit status
    By qtnewbie123 in forum Installation and Deployment
    Replies: 9
    Last Post: 12th July 2011, 19:51
  2. Collect2:Id Returned 1 exit status
    By c_srikanth1984 in forum Qt Programming
    Replies: 9
    Last Post: 14th February 2010, 05:58
  3. "Normal" Status Bar Message doesn't look right...
    By codeslicer in forum Qt Programming
    Replies: 4
    Last Post: 20th January 2009, 00:50
  4. Status Bar in a SUB WINDOW.
    By Cutey in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 08:42
  5. Status Widget
    By user_mail07 in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2008, 08:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.