39

How do I set the title of a QMainWindow?

I tried googling and found setCaption(), but it appears it no longer works in Qt 4.

houbysoft
  • 32,532
  • 24
  • 103
  • 156

1 Answers1

67

The method is setWindowTitle():

setWindowTitle(const QString &)

http://doc.qt.io/qt-4.8/qwidget.html#windowTitle-prop

Owen
  • 38,836
  • 14
  • 95
  • 125
Edward Strange
  • 40,307
  • 7
  • 73
  • 125
  • 1
    setCaption is supposed to do the same thing, though its deprecated now which I guess due to bad API naming. – ismail Dec 28 '10 at 22:05
  • 3
    Well, I was trying setTitle(), and when it didn't work, tried searching the Public Functions of QMainWindow in the Qt Assistant for title and it didn't find this. Anyway, thanks. – houbysoft Dec 28 '10 at 22:13
  • 1
    The confusion could come from the fact that `setWindowTitle` is a method of `QWidget`, not `QMainWindow`, even though the concept of “window title” is not even applicable to most widgets. – bdesham Oct 02 '14 at 19:55
  • @bdesham, actually you can make a window out of any widget if you just tell it to exec(). If you actually really want to do that is another thing. – Veda Feb 13 '17 at 18:20