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. QWidget top level widget
Forum Updated to NodeBB v4.3 + New Features

QWidget top level widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 5 Posters 2.8k Views 3 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 Alexey Serebryakov

    @mrjj yep.
    So, I have Qt-widget based application. Also I have notification widget which must be pop up on the selected screen/monitor in right bottom corner. Like Windows notification center or how in MS Outlook.
    User can select the screen which display that popup widget.
    Idially I need something like this:

    MyPopupWidget::show(QScreen *screen) {
      show();
      windowHandle()->setScreen(screen);
    }
    
    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #11

    @Alexey-Serebryakov
    Ohh.
    Like Win 10 Toast messages?

    But you must run on other platforms and prefer your own ?

    https://doc.qt.io/qt-5/qtwidgets-desktop-systray-example.html

    also for full blown usage
    https://github.com/mohabouje/WinToast

    A 1 Reply Last reply
    0
    • mrjjM mrjj

      @Alexey-Serebryakov
      Ohh.
      Like Win 10 Toast messages?

      But you must run on other platforms and prefer your own ?

      https://doc.qt.io/qt-5/qtwidgets-desktop-systray-example.html

      also for full blown usage
      https://github.com/mohabouje/WinToast

      A Offline
      A Offline
      Alexey Serebryakov
      wrote on last edited by
      #12

      @mrjj yes, like Win 10 Toast.
      Application run on Windows 10 and Ubuntu. So I need show custom popup widget. :-(
      Thank you but built-in systray not allowed.

      mrjjM 1 Reply Last reply
      0
      • A Alexey Serebryakov

        @mrjj yes, like Win 10 Toast.
        Application run on Windows 10 and Ubuntu. So I need show custom popup widget. :-(
        Thank you but built-in systray not allowed.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #13

        @Alexey-Serebryakov

        Ok, it must be totally custom.
        QSystray also had issues on ubuntu over the years.

        So is the message also clickable like Toats are or is it more like a tooltip type ?

        A 1 Reply Last reply
        0
        • mrjjM mrjj

          @Alexey-Serebryakov

          Ok, it must be totally custom.
          QSystray also had issues on ubuntu over the years.

          So is the message also clickable like Toats are or is it more like a tooltip type ?

          A Offline
          A Offline
          Alexey Serebryakov
          wrote on last edited by Alexey Serebryakov
          #14

          @mrjj Yes there popup widget has title, text, image, close button, links and so on. User can click them and follow to the main window by context dependency. Also popup widget can contain other user-defined custom widget.

          mrjjM 1 Reply Last reply
          0
          • A Alexey Serebryakov

            @mrjj Yes there popup widget has title, text, image, close button, links and so on. User can click them and follow to the main window by context dependency. Also popup widget can contain other user-defined custom widget.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #15

            @Alexey-Serebryakov

            Oh so its a FancyToast widget ;)

            Well it should not be that hard to place it. and the rich part sounds lovely.

            Do notice on some virtual Desktops, its like one big screen and you will have to move your window
            to right x pos as there will be only 1 screen.

            A 2 Replies Last reply
            0
            • mrjjM mrjj

              @Alexey-Serebryakov

              Oh so its a FancyToast widget ;)

              Well it should not be that hard to place it. and the rich part sounds lovely.

              Do notice on some virtual Desktops, its like one big screen and you will have to move your window
              to right x pos as there will be only 1 screen.

              A Offline
              A Offline
              Alexey Serebryakov
              wrote on last edited by Alexey Serebryakov
              #16

              @mrjj what the FancyToast?

              1 Reply Last reply
              0
              • mrjjM mrjj

                @Alexey-Serebryakov

                Oh so its a FancyToast widget ;)

                Well it should not be that hard to place it. and the rich part sounds lovely.

                Do notice on some virtual Desktops, its like one big screen and you will have to move your window
                to right x pos as there will be only 1 screen.

                A Offline
                A Offline
                Alexey Serebryakov
                wrote on last edited by
                #17

                @mrjj yeah virtual desktop is next my head ache... :-)

                1 Reply Last reply
                0
                • Axel SpoerlA Offline
                  Axel SpoerlA Offline
                  Axel Spoerl
                  Moderators
                  wrote on last edited by
                  #18

                  Instantiating a QWidget and calling show()create a series of events that get processed asynchronously. It cannot be safely assumed that windowHandle()returns a valid pointer right after construction and/or calling show(). You might be more lucky on Win10, than on UBuntu/X11.

                  If you want to wait for the widget to be fully constructed, you have to wait for windowHandle() != nullptr, e.g. by

                  while (!w1.windowHandle())
                      a.processEvents();
                  

                  QWindow::isExposed()tells if the window has been rendered on a screen.

                  Software Engineer
                  The Qt Company, Oslo

                  A 1 Reply Last reply
                  2
                  • Axel SpoerlA Axel Spoerl

                    Instantiating a QWidget and calling show()create a series of events that get processed asynchronously. It cannot be safely assumed that windowHandle()returns a valid pointer right after construction and/or calling show(). You might be more lucky on Win10, than on UBuntu/X11.

                    If you want to wait for the widget to be fully constructed, you have to wait for windowHandle() != nullptr, e.g. by

                    while (!w1.windowHandle())
                        a.processEvents();
                    

                    QWindow::isExposed()tells if the window has been rendered on a screen.

                    A Offline
                    A Offline
                    Alexey Serebryakov
                    wrote on last edited by
                    #19

                    @Axel-Spoerl thank you,
                    consider example code above,
                    how can I show w1 widget on first monitor and w2 on second?
                    Now both widgets showing on the same primary monitor.

                    Axel SpoerlA 1 Reply Last reply
                    0
                    • A Alexey Serebryakov

                      @Axel-Spoerl thank you,
                      consider example code above,
                      how can I show w1 widget on first monitor and w2 on second?
                      Now both widgets showing on the same primary monitor.

                      Axel SpoerlA Offline
                      Axel SpoerlA Offline
                      Axel Spoerl
                      Moderators
                      wrote on last edited by Axel Spoerl
                      #20

                      how can I show w1 widget on first monitor and w2 on second?

                      Suggest you take a look at the documentation and examine QWidget::setScreen(QScreen *screen).

                      Software Engineer
                      The Qt Company, Oslo

                      1 Reply Last reply
                      0
                      • A Alexey Serebryakov

                        @mrjj is it correct code?

                        class Widget : public QWidget
                        {
                            Q_OBJECT
                        public:
                             Widget(QWidget *parent = nullptr) : QWidget(parent, Qt::Window) {}
                            ~Widget();
                        };
                        
                        int main(int argc, char *argv[])
                        {
                            QApplication a(argc, argv);
                        
                            Widget w1;
                            Widget w2;
                        
                            w1.show();
                            w1.windowHandle()->setScreen(QApplication::screens()[0]);
                        
                            w2.show();
                            w2.windowHandle()->setScreen(QApplication::screens()[1]);
                        
                            return a.exec();
                        }
                        
                        Z Offline
                        Z Offline
                        zoujiu
                        wrote on last edited by
                        #21

                        @Alexey-Serebryakov thank you

                        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