No taskbar entry for QDialog using console application
-
I am writing a Qt Console Application using Qt Creator 4.6.0 in Linux. I would like to show a QDialog but I do not want it to
- show an entry on taskbar, and
- steal focus from other windows.
How can I do this?
I found kind of similar question, but the solutions does not work for me as it seems that I can's use
this
in console application.Here is what I have so far which shows the dialog but it neither hides it form taskbar nor prevents it from stealing the focus:
QDialog splash; QVBoxLayout *laySplash = new QVBoxLayout(&splash); splash.setAttribute(Qt::WA_ShowWithoutActivating); splash.setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); QLabel *lblText = new QLabel; laySplash->addWidget(lblText); lblText->setText(QString::fromStdString("test")); QTimer::singleShot(1000, &splash, SLOT(close())); splash.exec();
-
@Neshom said in No taskbar entry for QDialog using console application:
Qt Console Application using Qt Creator 4.6.0 in Linux. I would like to show a QDialog
What do you want to achieve exactly?
Console applications just interact with the console normally and have no visual elements. -
Hi @Neshom,
I'd fully agree to @raven-worx that console apps shouldn't use graphical elements.
Just a side node:
lblText->setText(QString::fromStdString("test"));
That looks odd. You're converting a char array to a
std::string
to convert it to aQString
. Better use:lblText->setText(QStringLiteral("test")); // for string constants lblText->setText(tr("test")); // for user output - makes it translateable
Regards
-
@JonB said in No taskbar entry for QDialog using console application:
@Neshom
E.g. https://stackoverflow.com/questions/4055506/qt-hide-taskbar-item seems to offer several ways (flags) to achieve this?None of these solution works for me. I am using Lubuntu. Can this be the reason?
-
@Neshom
I would guess that is indeed the reason if none of those work! It always helps if you tell us which OS you are under, especially if it's not Windows! I would imagine this is a desktop-thing, so more than Lubuntu what is probably relevant is which desktop manager you are using. And it may be that your manager does not allow you not to have an icon.... -
@JonB said in No taskbar entry for QDialog using console application:
@Neshom
I would guess that is indeed the reason if none of those work! It always helps if you tell us which OS you are under, especially if it's not Windows! I would imagine this is a desktop-thing, so more than Lubuntu what is probably relevant is which desktop manager you are using. And it may be that your manager does not allow you not to have an icon....I am using Linux - Lubuntu which has LXDE. Is there anyway to fix this? Is there any other way in QT to show a frame-less window/dialog/message/label/etc without a task-bar entry?