Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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();
        tabTitle.append("\n");
        tabTitle.append(contact.getUid());
    
        QListView* messengerListView = new QListView();
        getListViewModel(messengerListView);
        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:
    ba14daa3-31c6-44e1-838b-ddf1f41a6b43-image.png

    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

    Hi,

    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:

    this->tabs->setElideMode(Qt::ElideNone);
    

    Marking this as solved


Log in to reply