Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tab text gets cut off with a new line charater QTabWidget
Forum Updated to NodeBB v4.3 + New Features

Tab text gets cut off with a new line charater QTabWidget

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jdawg287
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      4
      • SGaistS SGaist

        Hi,

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

        J Offline
        J Offline
        Jdawg287
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved