Results 1 to 2 of 2

Thread: cannot change main window title

  1. #1
    Join Date
    Feb 2011
    Posts
    31
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy cannot change main window title

    a very basic and simple question which is puzzling me

    i want to change the title of the main window in my qt application (the GUI has been designed by Qt Design so I have the ui. and setupui() stuff)

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent)
    3. {
    4. QString windowTitle("some good stuf here");
    5. QMessageBox::information(this, progName, windowTitle );
    6.  
    7. //....
    8. this->setWindowTitle(windowTitle); // ???
    9.  
    10. ledGreen.load(":/bitmap/LED-Green-20.bmp");
    11. ledRed.load(":/bitmap/LED-Red-20.bmp");
    12. ledDark.load(":/bitmap/LED-Dark-20.bmp");
    13. ui.setupUi(this);
    14.  
    15. //....
    16. }
    To copy to clipboard, switch view to plain text mode 

    can't understand what is wrong here ...

    thanks much

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: cannot change main window title

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent)
    3. {
    4. QString windowTitle("some good stuf here");
    5. QMessageBox::information(this, progName, windowTitle );
    6.  
    7. //....
    8. //this->setWindowTitle(windowTitle); // ??? //<<<<<<<<<<<<<<<<<<<<<< Move it, after setupUi();
    9.  
    10. ledGreen.load(":/bitmap/LED-Green-20.bmp");
    11. ledRed.load(":/bitmap/LED-Red-20.bmp");
    12. ledDark.load(":/bitmap/LED-Dark-20.bmp");
    13. ui.setupUi(this);
    14.  
    15. this->setWindowTitle(windowTitle); //<<<<<<<<<<<<<<<<<<<<<<Here
    16.  
    17. //....
    18. }
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    marco.stanzani (3rd January 2013)

Similar Threads

  1. Replies: 6
    Last Post: 8th May 2011, 18:52
  2. Replies: 2
    Last Post: 17th February 2011, 12:30
  3. Replies: 3
    Last Post: 23rd December 2010, 06:55
  4. Replies: 11
    Last Post: 11th August 2008, 09:14
  5. Replies: 15
    Last Post: 23rd March 2007, 16:16

Tags for this Thread

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.