System tray icon disappears after a QInputDialog::getText
-
Hi,
I'm building an app for recognising music played by speakers and suggesting links.No MainWindow, it's a background app with a System tray icon.
I'm using QtCreator.
I have a problem with QInputDialog::getText , once I click on OK, the system tray icon disappears and I have to force to quit the app via QtCreator. Note that the background process still works after the icon disappears from the system tray, and that, in the code I wrote, the value saved in "apikey.txt" is correctly changed.
Here is the piece of code, and you will also find a part of the source code:
@void Window::changeTexte16()
{
bool dialogResult;
QString key;
QFile keyFile("apikey.txt");if(!keyFile.exists()){ keyFile.open(QIODevice::WriteOnly); QTextStream keyStream1(&keyFile); keyStream1 << "XXXXXXXXXXXXXXXXX"; keyFile.close(); } // Open apikey.txt and copy content in key (string) keyFile.open(QIODevice::ReadOnly); QTextStream keyStream2(&keyFile); key = keyStream2.readLine(); keyFile.close(); QString result = QInputDialog::getText(this, "Echonest API Key", "Enter your API key:", QLineEdit::Normal, key, &dialogResult); if(dialogResult) { keyFile.open(QIODevice::WriteOnly); QTextStream keyStream3(&keyFile); keyStream3 << result; keyFile.close(); }
}@
"the source code":http://www.qtfr.org/img/members/146981/main.zip
thanks in advance for the help
-
Hi and welcome to devnet,
You need to add which Qt/OS combo you are currently using
-
thank you,
5.2.1 and Windows 8, but I want it to work also on Win 7 (+ Vista and Xp if possible)
-
32 bits
-
Can you first update to 5.3.1 ?
-
is there a way to update or shall I install the entire 5.3.1, because when I select C:/Qt for instalation, it says to change folder because an instalation already exist (the 5.2.1)
-
- -> this instalation : Qt Online Installer for Windows (14 MB)
-
ok i'm installing the 5.3.1
-
same problem
-
the icon disapear after the QInputDialog::getText action
-
Ok, can you reproduce this with a minimal example ?
-
good idea, i'll try it
-
it also does not work with a minimal exemple :
"icon_hidden":http://www.qtfr.org/img/members/146981/icon_hidden.zip
-
in main :
if i replace w.hide(); by w.show(); the problem is fixed BUT a window is showed, even with a resize(0,0); and I don't want any window, just a system tray icon, so i must have w.hide(); in my code
how shall I do? -
You are missing
@a.setQuitOnLastWindowClosed(false);@
-
great !!!
thank u for your help. -
You welcome !
Now that you have your application working, please update the thread title prepending [solved] so that other forum users may know a solution has been found :)