17
votes

I'm developping a Qt application

I managed to set the main window title using methode

setWindowTitle("my title");

however this changes the name in the application top bar, it doesn't affect the title displayed in the top bar of gnome shell (ubuntu) nor the title displayed when doing alt+tab.

How to change it ?

I've tried using the DEPLOYMENT.display_name variable in my .pro file

4

4 Answers

10
votes

Try using QCoreApplication::setApplicationName("your title") in your main code.

6
votes

Once properly set programmatically, to get the application name for use as title just use the static getter method QCoreApplication::applicationName() or QtGUIApplication::applicationDisplayName() (since V5).

From V5, these will fall back to the executable name if the property is not set.

Example use:

QCoreApplication::setApplicationName( QString("My Application") );
setWindowTitle( QCoreApplication::applicationName() );

Alternatively, set the Window title with Qt Designer and access it with windowTitle().

3
votes

The application name is distinct from the window title. The window manager usually draws the window title into the title bar of the (main) window, while the application name is used by (e.g. Gnome) to represent the application itself.

Qt seems to be passing on the first argument's first item of its constructor's signature to the underlying window-manager:

app = QApplication(('My Application Name',))

QApplication.applicationName seems to be mainly used for application-internal purposes.


A more complete (basic) set-up would then look something like this (in Python, C++ would be analogous) - not the invocation of MyQApplication's superclass's constructor:

from PySide import QtCore, QtGui
import sys


class MyQApplication(QtGui.QApplication):
    def __init__(self, app_name):
        super(MyQApplication, self).__init__((app_name,))

        self.setApplicationName(app_name)

        self.main_window = QtGui.QMainWindow()
        self.main_window.setWindowTitle("My Application's Main Window")
        self.main_window.show()


if __name__ == '__main__':
    app = MyQApplication("My Application's Name")
    sys.exit(app.exec_())

0
votes

You can go to the Designer in Qt Creator and change the title of the object in settings,which are on the right side.