Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a popped-up window a top-level window in QT?
    text
    copied!<p>In QT, when a button is clicked and a window pops up, the user can still go back and click the same button (infinite times). How can I make it so that the window that pops up from the button stays on top of the other windows? In this case, it is the "Edit" button that pops up a window.</p> <p>Here is window.cpp</p> <pre><code>#include "window.h" #include "editwindow.h" #include "ui_window.h" #include &lt;QtGui/QApplication&gt; #include &lt;QtGui&gt; Window::Window(QWidget *parent) : QDialog(parent), ui(new Ui::Window) { ui-&gt;setupUi(this); ShowEdit = new QPushButton(tr("Edit")); ShowEdit -&gt; show(); connect(ShowEdit, SIGNAL(clicked()), this, SLOT(popup())); Remove = new QPushButton(tr("Remove")); Remove -&gt; show(); connect(Remove, SIGNAL(clicked()), this, SLOT(ProgramRemove())); OK = new QPushButton(tr("OK")); OK -&gt; show(); connect(OK, SIGNAL(clicked()), this, SLOT(Saved())); Quit = new QPushButton(tr("Quit")); Quit -&gt; show(); connect(Quit, SIGNAL(clicked()), this, SLOT(close())); QLabel *tableLabel = new QLabel(tr("All Programs")); QVBoxLayout *buttonLayout2 = new QVBoxLayout; buttonLayout2 -&gt; addWidget(ShowEdit); buttonLayout2 -&gt; addWidget(Remove); //buttonLayout2 -&gt; addStretch(); QHBoxLayout *buttonLayout2_2 = new QHBoxLayout; buttonLayout2_2 -&gt; addWidget(Quit); buttonLayout2_2 -&gt; addWidget(OK); /*******************************************************************************/ /***************************Below is for Table**********************************/ /*******************************************************************************/ PTable = new QTableWidget(10, 10); //PTable -&gt;setHorizontalHeader(tr("Program Names")); //inputs-&gt;setText(QString::number(row)); //PTable-&gt;setItem(row, column, inputs); QHBoxLayout *PTableLayout = new QHBoxLayout; PTableLayout -&gt;addWidget(PTable); /*------------------------------------------------------------------------------*/ /*------------------------construct window--------------------------------------*/ /*------------------------------------------------------------------------------*/ QGridLayout *SecondLayout = new QGridLayout; SecondLayout -&gt; addWidget(tableLabel, 0, 0); SecondLayout -&gt; addLayout(PTableLayout, 1, 0); SecondLayout -&gt; addLayout(buttonLayout2, 0, 1); SecondLayout -&gt; addLayout(buttonLayout2_2, 2, 0); setLayout(SecondLayout); setWindowTitle(tr("Settings")); } Window::~Window() { delete ui; } void Window :: popup() { EditWindow* window_3 = new EditWindow(this); window_3-&gt;move(QPoint(550, 100)); window_3-&gt;show(); window_3-&gt;raise(); } void Window :: closeBoth() { return; } void Window :: Saved() { return; } void Window :: ProgramRemove() { return; } </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