title: QStyledItemDelegate - show button menu as soon as the editor is created
body: <p>I have a QTableView which shows a &quot;Color&quot; column, upon which the user clicks, a button with menu, which has a color picker widget should be created. I don't have issue with creating and displaying this button on the table cell. But my concern is that to get to the color picker widget and select the proper color, user has to do 3 clicks.</p>
  <ol>
  <li>First click - Cell becomes editable and the button appears</li>
  <li>Second click - Button displays the menu with color picker widget.</li>
  <li>Third click - User selects the desired color from color picker
  widget</li>
  </ol>
  <p>I want to reduce this to two clicks, so that user should be able to achieve all the above. That is,</p>
  <ol>
  <li>First click - Cell becomes editable and the button appears, at the
  same time menu with color picker also shows up</li>
  <li>Second click - User selects the desired color from picker</li>
  </ol>
  <p>What I was trying to do calling colorButton-&gt;showMenu() in different places of QStyledItemDelegate overriden functions, for example in setEditorData() like this.</p>
  <pre><code>void qDrawToolsDelegate_C::setEditorData(QWidget * editor, const QModelIndex &amp; index) const
  {
      if (!index.isValid() || !editor) return;
      const qDrawToolsModel_C * model = static_cast&lt;const qDrawToolsModel_C *&gt;(index.model());
      if (!model) return;
      if (model-&gt;columnType(index.column()) == COL_TYPE_COLOR) {
          qColorButton_C * colorButton = static_cast&lt;qColorButton_C *&gt;(editor);
          colorButton-&gt;setColor(_model-&gt;getColor(index));
          colorButton-&gt;showMenu();
      }
      else QStyledItemDelegate::setEditorData(editor, index);
  }
  </code></pre>
  <p>The menu shows up, but the button doesn't seem to appear properly. I assume that the menu pops up before the painting on button is complete. See picture 1 (click on Red cell).</p>
  <p><a href="https://i.stack.imgur.com/6v39H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6v39H.png" alt="Menu pops up when clicked on the cell, but the button is not visible" /></a></p>
  <p>When the popup is closed, the button draws properly. See picture 2.</p>
  <p><a href="https://i.stack.imgur.com/Q3dkO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q3dkO.png" alt="Button draws properly after popup menu is closed" /></a></p>
  <p>I'm not sure how showing popup blocks the painting on the button. If it is really because of that, I can think of creating a timer and then call showMenu() in timer slot to solve this. But I like you guys' suggestions on how to achieve this better.</p>
  <p>PS: I just RTFM :). It says about showMenu() -&quot;This function does not return until the popup menu has been closed by the user.&quot;</p>