Unsolved Multiple app icons on launch bar for single Qt app
-
Hi
I have a QInputDialog open before my main window and after input and click OK, it closes and my main window opens. However, in my app launcher (the vertical bar holding app icons on the left of screen in Ubuntu), it remains two icons. How should I keep it only one single icon for one application?
-
@dalishi said in Multiple app icons on launch bar for single Qt app:
it closes
Do you delete that dialog also?
-
@jsulm i'm using
int id = QInputDialog::getInt(this, tr("Domain id"), tr("domain_id:"), 0, 0, 100, 1, &ok);
Have no idea how to delete?
-
@dalishi is this inside main?
with a this pointer I can answer my question with no, it's not... -
@dalishi No need to delete in this case.
I don't know why this happens, could be an issue in Canonicals Unity desktop environment. Did you test with any other Linux desktop environment? -
@J.Hilk This is inside the constructor of my main window which is inherited from MainOpenGLWidget.
-
@jsulm i have not tested on other linux desktops. Funny thing is this happens most of the time but not all the time. Very few time it works fine with one single app icon shown.
-
@dalishi Try to remove it from where and call it in main instead
-
@jsulm Hi i move the call to main however the content of the window does not draw.
bool ok; int domain_id = QInputDialog::getInt(nullptr, QObject::tr("Domain id"), QObject::tr("domain_id:"), 0, 0, 100, 1, &ok); if (ok) { // ok pressed MainWindow w(domain_id); w.show(); } else { // do nothing } return a.exec();
Remove the if-else it works....
bool ok; int domain_id = QInputDialog::getInt(nullptr, QObject::tr("Domain id"), QObject::tr("domain_id:"), 0, 0, 100, 1, &ok); MainWindow w(domain_id); w.show(); return a.exec();
-
well yes, of course, as soon as the scope closes
}
the MainWindow is destroyed, as it is on the stack and only exists inside the scope of the if condition! -
hi
Seems you just want.MainWindow w(domain_id); if (ok) { // ok pressed w.show(); } else { // do nothing } return a.exec();
-
@mrjj Hi thanks for the code. However, in this way, the mainwindow will be constructed anyway no matter the user click OK or Cancel. So i come up with the following:
bool ok; int domain_id = QInputDialog::getInt(nullptr, QObject::tr("Domain id"), QObject::tr("domain_id:"), 0, 0, 100, 1, &ok); if (ok) { // ok pressed MainWindow w(domain_id); w.show(); return a.exec(); } else { // Cancel pressed or message box closed return 0; }
However, this still can not solve the double app icon problem. It seems randomly the first dialog icon just does not want to disappear.