Nominate our 2022 Qt Champions!

Tab text gets cut off with a new line charater QTabWidget

  • I am developing a chat application and need to display the name and id for each contact on a different tab. So, I am using a new line character to separate the name and the id and setting the result as the title of the tab as follows:

    bool MessengerPage::addNewTab(const Contact& contact)
        std::string tabTitle = contact.getName();
        QListView* messengerListView = new QListView();
        this->tabs->addTab(messengerListView, QString::fromStdString(tabTitle));
        contactsList.insert(std::pair<std::string, Contact>(contact.getUid(), contact));
        return true;

    QListView is being used to display all the messages in the code above.
    Now since this is a project for multiple platforms, I need this to work for all platforms.
    Until now I had no problem for the display on Linux as can be seen:

    But it is being displayed as follows on MacOS:
    Screen Shot 2019-11-27 at 15.56.31.png

    I have tried solutions which require fiddling with the CSS but to no avail.
    Does anybody have any idea how to fix this? Any help would be appreciated. Thanks.

  • Lifetime Qt Champion


    Did you try to set the elideMode property to Qt::ElideNone ?

  • @SGaist Wow thanks that just did it!
    You are a life saver. Thanks!

    This is the fix:


    Marking this as solved

Log in to reply