title: Qt QGridLayout how to adjust widget width and height
body: <p>I am trying to adjust a LineEdit and PushButton width in a QDialog window. The LineEdit should be 20 times wider than then button, so it's long enough to show the whole path. Below is my code, I tried several ways, but they all got similar layout (see screenshot). I want to make the Option window at least 2 times wider to make the LineEdit wide enough. How should I do that?</p>
  
  <p><img src="https://i.stack.imgur.com/AJam5.png" alt="enter image description here"></p>
  
  <p>This is my code:</p>
  
  <pre><code>  this-&gt;setWindowTitle(tr("Options"));
  
    QGridLayout* logLayout = new QGridLayout;
  
    QLineEdit _logPathLE = new QLineEdit;
    logLayout-&gt;addWidget(_logPathLE, 0, 0);
    logLayout-&gt;setColumnStretch(0, 20);  // 1st: try with setStretch
    //_logPathLE-&gt;setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);  // 2nd try with setSizePolicy
    //logLayout-&gt;addWidget(logLocation, 0, 0, 0, 20);  // 3rd: try with span multiple columns
  
    QPushButton* browseFolder = new QPushButton(tr("..."));
    logLayout-&gt;addWidget(browseFolder, 0, 1);
    logLayout-&gt;setColumnStretch(1, 1);
    //browseFolder-&gt;setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    //logLayout-&gt;addWidget(browseFolder, 0, 20, 0, 1);
  
    QGroupBox* optGroupBox = new QGroupBox(tr("Log location"));
    optGroupBox-&gt;setLayout(logLayout);
  
    QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(btns, SIGNAL(accepted()), this, SLOT(accept()));
    connect(btns, SIGNAL(rejected()), this, SLOT(reject()));
  
    QVBoxLayout* options = new QVBoxLayout;
    options-&gt;addWidget(optGroupBox);
    options-&gt;addWidget(btns);
  
    this-&gt;setLayout(options);
  </code></pre>