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. QSystemTrayIcon hide() crash on mac while I use QTimer to change the icon of QSystemTrayIcon
Qt 6.11 is out! See what's new in the release blog

QSystemTrayIcon hide() crash on mac while I use QTimer to change the icon of QSystemTrayIcon

Scheduled Pinned Locked Moved General and Desktop
21 Posts 5 Posters 25.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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #9

    strange , when I edit it , the format looks well , but why when I post , it is so ugly .

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #10

      [quote author="brucewuu" date="1309868142"]@//! [6]

      void Window::messageClicked()
      {
      QMessageBox::information(0, tr("Systray"),
      tr("Sorry, I already gave what help I could.n"
      "Maybe you should try asking a human?"));
      }

      //! [6]

      void Window::createIconGroupBox()
      {
      iconGroupBox = new QGroupBox(tr("Tray Icon"));

      iconLabel = new QLabel("Icon:");
      
      iconComboBox = new QComboBox;
      iconComboBox->addItem(QIcon(":/images/bad.svg"), tr("Bad"));
      iconComboBox->addItem(QIcon(":/images/heart.svg"), tr("Heart"));
      iconComboBox->addItem(QIcon(":/images/trash.svg"), tr("Trash"));
      
      showIconCheckBox = new QCheckBox(tr("Show icon"));
      showIconCheckBox->setChecked(true);
      
      QHBoxLayout *iconLayout = new QHBoxLayout;
      iconLayout->addWidget(iconLabel);
      iconLayout->addWidget(iconComboBox);
      iconLayout->addStretch();
      iconLayout->addWidget(showIconCheckBox);
      iconGroupBox->setLayout(iconLayout);
      

      }

      void Window::createMessageGroupBox()
      {
      messageGroupBox = new QGroupBox(tr("Balloon Message"));

      typeLabel = new QLabel(tr("Type:"));
      
      typeComboBox = new QComboBox;
      typeComboBox->addItem(tr("None"), QSystemTrayIcon::NoIcon);
      typeComboBox->addItem(style()->standardIcon(
              QStyle::SP_MessageBoxInformation), tr("Information"),
              QSystemTrayIcon::Information);
      typeComboBox->addItem(style()->standardIcon(
              QStyle::SP_MessageBoxWarning), tr("Warning"),
              QSystemTrayIcon::Warning);
      typeComboBox->addItem(style()->standardIcon(
              QStyle::SP_MessageBoxCritical), tr("Critical"),
              QSystemTrayIcon::Critical);
      typeComboBox->setCurrentIndex(1);
      
      durationLabel = new QLabel(tr("Duration:"));
      
      durationSpinBox = new QSpinBox;
      durationSpinBox->setRange(5, 60);
      durationSpinBox->setSuffix(" s");
      durationSpinBox->setValue(15);
      
      durationWarningLabel = new QLabel(tr("(some systems might ignore this "
                                           "hint)"));
      durationWarningLabel->setIndent(10);
      
      titleLabel = new QLabel(tr("Title:"));
      
      titleEdit = new QLineEdit(tr("Cannot connect to network"));
      
      bodyLabel = new QLabel(tr("Body:"));
      
      bodyEdit = new QTextEdit;
      bodyEdit->setPlainText(tr("Don't believe me. Honestly, I don't have a "
                                "clue.nClick this balloon for details."));
      
      showMessageButton = new QPushButton(tr("Show Message"));
      showMessageButton->setDefault(true);
      
      QGridLayout *messageLayout = new QGridLayout;
      messageLayout->addWidget(typeLabel, 0, 0);
      messageLayout->addWidget(typeComboBox, 0, 1, 1, 2);
      messageLayout->addWidget(durationLabel, 1, 0);
      messageLayout->addWidget(durationSpinBox, 1, 1);
      messageLayout->addWidget(durationWarningLabel, 1, 2, 1, 3);
      messageLayout->addWidget(titleLabel, 2, 0);
      messageLayout->addWidget(titleEdit, 2, 1, 1, 4);
      messageLayout->addWidget(bodyLabel, 3, 0);
      messageLayout->addWidget(bodyEdit, 3, 1, 2, 4);
      messageLayout->addWidget(showMessageButton, 5, 4);
      messageLayout->setColumnStretch(3, 1);
      messageLayout->setRowStretch(4, 1);
      messageGroupBox->setLayout(messageLayout);
      

      }

      void Window::createActions()
      {
      minimizeAction = new QAction(tr("Mi&nimize"), this);
      connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));

      maximizeAction = new QAction(tr("Ma&ximize"), this);
      connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
      
      restoreAction = new QAction(tr("&Restore"), this);
      connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
      
      quitAction = new QAction(tr("&Quit"), this);
      connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
      

      }

      void Window::createTrayIcon()
      {
      trayIconMenu = new QMenu(this);
      trayIconMenu->addAction(minimizeAction);
      trayIconMenu->addAction(maximizeAction);
      trayIconMenu->addAction(restoreAction);
      trayIconMenu->addSeparator();
      trayIconMenu->addAction(quitAction);

      trayIcon = new QSystemTrayIcon(this);
      trayIcon->setContextMenu(trayIconMenu);
      

      }
      @
      is this a qt bug ? or something I did wrong somewhere[/quote]

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #11

        If you start and end your code section in your post with an 'at' sign ('@') it will look much nicer. That is what the others are asking for.

        I have just added in the post above these two signs in the begin at the end. And voila it looks much better.

        Sorry, had to do two posts ;-)

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #12

          there is a wiki page explaining how the editor works :
          "Using the editor :":http://developer.qt.nokia.com/wiki/ForumHelp#9bd9c32b79efb1b2d5b039e4d48300a9

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #13

            ok , guys , thanks very much , I have changed them now ~~anyone could give me solution ?thanks

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #14

              It may be caused by some internal objects that are no longer available after you hide the icon. I can reproduce the crash on my Mac box.

              As a workaround you can replace the call to hide with a single shot timer in your slot like this

              @
              fSystemTrayTimer->stop() ;
              //fSystemTrayIcon->hide();
              QTimer::singleShot(0, fSystemTrayIcon, SLOT(hide()));
              @

              This way the call to hide is delivered after you have left the slot.

              EDIT:
              I've added this as a doc not to [[Doc:QSystemTrayIcon]] too.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #15

                thanks Volker , you are always the best problem solver for me . Great Appreciation ~~~

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #16

                  hi Volker , I also meet the same problem as the following link
                  http://svn.netlabs.org/qt4/ticket/201
                  do you have some solution for that ?thanks ~~

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #17

                    I'll have a look into this later.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #18

                      thanks very much , I have read the guide to ask questions , it is very helpful for me , thank you very much , I will do this better ~~

                      1 Reply Last reply
                      0
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #19

                        I didn't forget you but I was terribly busy the last week and am off for vacation soon, so please be a bit more patient.

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #20

                          thanks Volker ~~just have a look when you have time , thanks

                          1 Reply Last reply
                          0
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #21

                            [quote author="brucewuu" date="1309959197"]hi Volker , I also meet the same problem as the following link
                            http://svn.netlabs.org/qt4/ticket/201
                            do you have some solution for that ?thanks ~~[/quote]

                            That's out of scope for me. I don't know the internal workings for the OS/2 port, sorry.

                            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