Note that there are some explanatory texts on larger screens.

plurals
  1. POAutofocusing on QLineEdit in QDialog with Popup flag and modality over main window
    text
    copied!<p>I have a <code>QDialog</code> based class that contains <code>QLineEdit</code> and some buttons. It is invoked with context menu event from <code>QGraphicsScene</code> I would like it to behave as follows:</p> <ol> <li>Autofocus on <code>QLineEdit</code> when invoked ( <code>ui-&gt;lineEdit-&gt;setFocus()</code> is present in constructor)</li> <li>No taskbar icon and no frame (as for <code>Qt::Popup</code> flag)</li> <li>Modality over main window as for <code>parent=0</code></li> </ol> <p>Using <code>parent = 0</code> fulfils 1 and provides modality but also frame and taskbar icon.</p> <p><code>Qt::Popup</code> alone removes both frame and taskbar icon but also destroys focusing on <code>lineEdit</code> and modality.</p> <p>I will be grateful for any suggestions as I've lot of time over it trying to find right combination of different <code>WindowFlags</code> etc. Main problem seems to be that when any <code>WindowFlag</code> is applied or <code>parent</code> widget is defined the focusing on <code>lineEdit</code> is completely lost.</p> <pre><code>void GraphicsScene::resolveContextMenuAction_(QAction *action) { if(action == this-&gt;contextMenuEventOpenDialog_) { TestDialog* DWD = new TestDialog(0); //this-&gt;DWD-&gt;setWindowFlags(Qt::Popup) int result = DWD-&gt;exec(); ... } } </code></pre> <p>Constructor:</p> <pre><code>TestDialog::TestDialog(QWidget *parent) : QDialog(parent), ui(new Ui::TestDialog) { this-&gt;ui-&gt;lineEdit-&gt;setFocus(); } </code></pre> <p>Also the focus tab order was adjusted so that <code>lineEdit</code> is first one. In the worst case I would accept no modality as with <code>Qt::Popup</code> if only the other features mentioned are there.</p> <p>In case it is OS dependant - I'm using Ubuntu 12.04.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload