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. Increase the size of the box in a form to fit the text
Forum Updated to NodeBB v4.3 + New Features

Increase the size of the box in a form to fit the text

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k 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.
  • K Offline
    K Offline
    kanakas
    wrote on last edited by
    #1

    Hi,
    I have created some layouts to display a form, but the size of the linedit box with the
    “patient["clinical_department"]” or “patient["surname"])” are too small and the text doesn’t fit.
    What can I do?

    @layout = new QFormLayout;
    _layout3 = new QVBoxLayout(this);

    while(!patients3.isEmpty()) {
    QMap<QString,QString> patient = patients3.takeFirst();
    if (patient["id"]==itemId) {
    QLineEdit *MyLineEdit = new QLineEdit(patient["clinical_department"]);
    layout->addRow("ID",MyLineEdit);
    layout->addRow("Surname", new QLineEdit(patient["surname"]));
    }
    }
    listview->setLayout(layout);
    this->_layout3->addWidget(listview);
    }@

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      You have to calculate the required space depending on the text length using a font metric, and then set the preferred size of the line edit. But this does not seem a good option to me: what if the text is edited over the displayed size?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kanakas
        wrote on last edited by
        #3

        is there anything else that i can do?
        In addition how can i add scrollbars.
        I had creted a treewidget before and when i ran my application on my mobile phone, it autommatically displayed them.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kanakas
          wrote on last edited by
          #4

          Hi, I need a little help with my code. I am trying to put scrollbars on my code.
          It is a form that i would like to be in a groupbox and the groupbox in a qvboxlayout.

          @
          QVBoxLayout* _layout3;
          QFormLayout* layout;

          QScrollArea *scrollArea = new QScrollArea(this);
          scrollArea->setWidgetResizable(true);
          QGroupBox *groupBox = new QGroupBox(scrollArea);

          QWidget *baseArea = new QWidget();
          baseArea->setLayout(_layout3);
          scrollArea->setWidget(baseArea);
          
          while(!patients3.isEmpty()) {
              QMap<QString,QString> patient = patients3.takeFirst();
              if (patient["id"]==itemId) {
                  QLineEdit *MyLineEdit = new QLineEdit(patient["id"]);
                  layout->addRow("ID",MyLineEdit);
                  layout->addRow("Surname", new QLineEdit(patient["surname"]));
                  layout->addRow("Name", new QLineEdit(patient["name"]));
          }
          groupBox->setLayout(layout);
          scrollArea->widget()->setLayout(_layout3);
          

          this->_layout3->addWidget(groupBox);
          }@

          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