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. QComboBox - how to change text size ( pixels )
Forum Updated to NodeBB v4.3 + New Features

QComboBox - how to change text size ( pixels )

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 523 Views
  • 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.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by TomNow99
    #1

    Hi,

    I will start with picture:

    text.png

    I have QComboBox with QStandardItemModel and QStandardItems. That items have different long texts. For example here, one of my item has text:

    item->setText("very, very, very, very, very, very, very, very, very, very, very long text");

    I would like to display the shorter text. For example:

    text2.png

    That green arrow is only to show, where I would like to have free, white space ( right side from arrow ).

    But when the user click on item I would like get full text. How can I do that?

    EDIT:
    In initStyleOption() in delegate to item I write:

    QFont myFont(QFont(option->font));
    QFontMetrics fm(myFont);
    QString elidedText= fm.elidedText(index.data().toString(),Qt::ElideMiddle, 120);
    option->text=elidedText;
    

    But now I have other question:

    one.png

    This is one of my item in QComboBox. Width of this is 200, but the width, where I can display text is smaller, because the checkbox has a few pixels for self ( look at next picture and red line - this is that place, where I can't have text ).
    So I would like to get width the item in comboBox where I can have text ( so width of comboBox minus width of red line ).

    one2.png

    1 Reply Last reply
    0

    • Login

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