Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a popup window in Qt without a shadow
    text
    copied!<p>I'm developing an application using Qt 4.5 (under Windows Vista but want it to be cross platform). I'm using C++</p> <p>I'd like to create a popup window that that contains a QLineEdit widget, with the feature that when the user interacts with the QLineEdit widget, the popup window is not activated (the main application window remains active). </p> <p>Creating a window (widget) with the Qt::Popup | Qt::Window flags gives me exactly what I want, except i don't want the 3D shadow border effect this provides. I want a borderless window. Note that the Qt::FramelessWindowHint flag doesn't achieve this. </p> <p>Anyone got any clues?</p> <p>Further clarification: Below is a snippit from a simple test application that creates a window with a button in it. When the button is pressed, a popup window is shown and the user can type into a QLineEdit box. When the user does this, the main window remains activated:</p> <p><a href="http://howlettresearch.com/popup_img_1.png" rel="noreferrer">http://howlettresearch.com/popup_img_1.png</a></p> <p>However, note the shadow border on the popup window (I have been unable to get rid of this).</p> <p>By comparison, creating the window as in the commented out line allows a popup style window to be created without a shadow, but when the user clicks on the QLineEdit in the popup, the main window is no longer active. You can tell because the shadow on the main window has changed.</p> <p><a href="http://howlettresearch.com/popup_img_2.png" rel="noreferrer">http://howlettresearch.com/popup_img_2.png</a></p> <p>I'm really after a popup window which behaves as if it is part of the main window. As a side note, the popup window disappears when clicking outside it, but this is almost the behavior I want and I can work with this and grabMouse etc. to do what I want... provided I can get rid of that shadow! </p> <pre><code>PopupTest::PopupTest(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { QPushButton* pb = new QPushButton("test button"); setCentralWidget(pb); QObject::connect(pb, SIGNAL(clicked()), this, SLOT(handleClick())); } void PopupTest::handleClick() { //QFrame* popup1 = new QFrame(this, Qt::Tool | Qt::Window | Qt::FramelessWindowHint); QFrame* popup1 = new QFrame(this, Qt::Popup | Qt::Window ); popup1-&gt;resize(150,100); QLineEdit *tmpE = new QLineEdit( popup1 ); connect( tmpE, SIGNAL( returnPressed() ), popup1, SLOT( hide() ) ); tmpE-&gt;setGeometry(10,10, 130, 30); tmpE-&gt;setFocus(); popup1-&gt;show(); } PopupTest::~PopupTest() { } </code></pre>
 

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