Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. System tray icon disappears after a QInputDialog::getText

System tray icon disappears after a QInputDialog::getText

Scheduled Pinned Locked Moved General and Desktop
17 Posts 2 Posters 4.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AmirHammoutene
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You need to add which Qt/OS combo you are currently using

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AmirHammoutene
        wrote on last edited by
        #3

        thank you,

        5.2.1 and Windows 8, but I want it to work also on Win 7 (+ Vista and Xp if possible)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AmirHammoutene
          wrote on last edited by
          #4

          32 bits

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Can you first update to 5.3.1 ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AmirHammoutene
              wrote on last edited by
              #6

              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)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AmirHammoutene
                wrote on last edited by
                #7
                • -> this instalation : Qt Online Installer for Windows (14 MB)
                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AmirHammoutene
                  wrote on last edited by
                  #8

                  ok i'm installing the 5.3.1

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    AmirHammoutene
                    wrote on last edited by
                    #9

                    same problem

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      AmirHammoutene
                      wrote on last edited by
                      #10

                      the icon disapear after the QInputDialog::getText action

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Ok, can you reproduce this with a minimal example ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AmirHammoutene
                          wrote on last edited by
                          #12

                          good idea, i'll try it

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            AmirHammoutene
                            wrote on last edited by
                            #13

                            it also does not work with a minimal exemple :

                            "icon_hidden":http://www.qtfr.org/img/members/146981/icon_hidden.zip

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              AmirHammoutene
                              wrote on last edited by
                              #14

                              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?

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                You are missing

                                @a.setQuitOnLastWindowClosed(false);@

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  AmirHammoutene
                                  wrote on last edited by
                                  #16

                                  great !!!
                                  thank u for your help.

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    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 :)

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved