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. QAbstract button texts truncated in QMessageBox
Qt 6.11 is out! See what's new in the release blog

QAbstract button texts truncated in QMessageBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.3k 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.
  • A Offline
    A Offline
    Abhi_oct30
    wrote on last edited by
    #1

    Hi,

    My requirement is to add an long button text in QMessage Box. But Qt automatically resizes the button and a part of text in button is getting truncated and not displayed.
    As shown below for the center button.
    Can you please help and provide a solution so that it is not resized.

    Thanks in advance

    ![alt text](0_1508743141107_2953e7f2-b114-4790-92f7-8cbda530d4a8-image.png image url)

    QString _message = QObject::tr("Some expressions in the supercomponent being created will refer to"
    "a parameter defined outside the bounds of the supercomponent."
    "Do you want to:"
    "> - replace references to it with its current value"
    "- keep the parameter references as they are"
    " - create a new parameter in the supercomponent and reference this one instead?");

       QMessageBox question(QMessageBox::Question,
          QObject::tr("Global Parameters"),
          _message,
          QMessageBox::NoButton,
          NULL);
       question.adjustSize();
       QAbstractButton* replace_button = question.addButton(
          QObject::tr("Replace with values"), QMessageBox::AcceptRole);
       replace_button->setToolTip(QObject::tr("Each reference to a global parameter will be replaced\n"
          "with the value of the global parameter"));
       replace_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
       replace_button->adjustSize();
       //replace_button->setMinimumSize(QSize(0, 0));
       //replace_button->setMinimumSize(QSize(300, 300));
       QAbstractButton* keep_button = question.addButton(
          QObject::tr("Keep references1111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), QMessageBox::AcceptRole);
       keep_button->setToolTip(QObject::tr("References to global parameters are unchanged.\n"
          "It means the supercomponent will keep referring\n"
          "to the global parameters of the circuit"));
       keep_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
       //keep_button->setMinimumSize(QSize(0, 0));
       //keep_button->setMinimumSize(QSize(300,300));
       keep_button->adjustSize();
       QAbstractButton* create_button = question.addButton(
          QObject::tr("Create supercomponent parameters as it by default"), QMessageBox::AcceptRole);
       create_button->setToolTip(QObject::tr("Global parameters will be created\n"
          "and referenced in the supercomponent"));
       QSize trace = create_button->minimumSize();
       trace = create_button->maximumSize();
       create_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
       //create_button->setMinimumSize(QSize(0, 0));
       //create_button->setMinimumSize(QSize(400, 400));
       create_button->adjustSize();
       question.setMinimumSize(QSize(0, 0));
       question.setMaximumSize(QSize(200, 200));
       question.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
       question.exec();
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Did
      replace_button->setMinimumSize(QSize(300, 300));

      not work ?

      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