Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. No taskbar entry for QDialog using console application
Qt 6.11 is out! See what's new in the release blog

No taskbar entry for QDialog using console application

Scheduled Pinned Locked Moved Unsolved C++ Gurus
8 Posts 4 Posters 5.0k Views 2 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.
  • N Offline
    N Offline
    Neshom
    wrote on last edited by
    #1

    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

    1. show an entry on taskbar, and
    2. 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();
    
    raven-worxR aha_1980A 2 Replies Last reply
    0
    • N Neshom

      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

      1. show an entry on taskbar, and
      2. 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();
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • N Neshom

        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

        1. show an entry on taskbar, and
        2. 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();
        
        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 a QString. Better use:

         lblText->setText(QStringLiteral("test")); // for string constants
         lblText->setText(tr("test")); // for user output - makes it translateable
        

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Neshom
          wrote on last edited by
          #4

          I want the console application to show dialog which it does. However, it shows an entry on the taskbar for the dialog which I am trying to get rid of. Any suggestion?

          JonBJ 1 Reply Last reply
          0
          • N Neshom

            I want the console application to show dialog which it does. However, it shows an entry on the taskbar for the dialog which I am trying to get rid of. Any suggestion?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Neshom
            E.g. https://stackoverflow.com/questions/4055506/qt-hide-taskbar-item seems to offer several ways (flags) to achieve this?

            N 1 Reply Last reply
            0
            • JonBJ JonB

              @Neshom
              E.g. https://stackoverflow.com/questions/4055506/qt-hide-taskbar-item seems to offer several ways (flags) to achieve this?

              N Offline
              N Offline
              Neshom
              wrote on last edited by
              #6

              @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?

              JonBJ 1 Reply Last reply
              -1
              • N Neshom

                @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?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @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....

                N 1 Reply Last reply
                0
                • JonBJ JonB

                  @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....

                  N Offline
                  N Offline
                  Neshom
                  wrote on last edited by
                  #8

                  @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?

                  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