Alright, this seems to be something WM specific then. While it worked on Windows the window stays inactive on X11. Try this:
// main.cpp
#include <QtGui>
{
Q_OBJECT
public:
MainWindow
(QWidget* parent
= 0, Qt
::WindowFlags flags
= 0) {
}
public slots:
void activateWindow()
{
}
};
int main(int argc, char* argv[])
{
MainWindow win(0, Qt::Tool);
win.show(); // must be called before setting Qt::WA_QuitOnClose
win.setAttribute(Qt::WA_QuitOnClose);
QTimer::singleShot(0,
&win,
SLOT(activateWindow
()));
return app.exec();
}
#include "main.moc"
// main.cpp
#include <QtGui>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0)
: QMainWindow(parent, flags)
{
setCentralWidget(new QTextEdit(this));
}
public slots:
void activateWindow()
{
QMainWindow::activateWindow();
}
};
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MainWindow win(0, Qt::Tool);
win.show(); // must be called before setting Qt::WA_QuitOnClose
win.setAttribute(Qt::WA_QuitOnClose);
QTimer::singleShot(0, &win, SLOT(activateWindow()));
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
PS. Could you update your profile to indicate used platforms, please?
Bookmarks