QAbstract button texts truncated in QMessageBox



  • 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();

  • Qt Champions 2016

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

    not work ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.