Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. First time, button need double click to trigger. Next time, just one click.
QtWS25 Last Chance

First time, button need double click to trigger. Next time, just one click.

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
17 Posts 3 Posters 7.8k Views
  • 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.
  • H Hung Tran
    7 Apr 2017, 05:01

    @ambershark Thank for your support. I think my code is root cause issue happen. I will debug and show result late.

    Thank so much

    A Offline
    A Offline
    ambershark
    wrote on 7 Apr 2017, 05:17 last edited by
    #8

    @Hung-Tran You're welcome :) Let us know what you find out.

    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

    H 1 Reply Last reply 7 Apr 2017, 07:34
    1
    • A ambershark
      7 Apr 2017, 05:17

      @Hung-Tran You're welcome :) Let us know what you find out.

      H Offline
      H Offline
      Hung Tran
      wrote on 7 Apr 2017, 07:34 last edited by
      #9

      @ambershark

      Wow, It's difficult to explain to you. But I have short information to you:

      1. I use Qt for GUI that control action of player. And use GStreamer for playback. Don't playback by qt because qt can't control hardward as my expected.
      2. GUI action will call API of GStreamer.
      3. Before playback by Gstreamer, GUI action as expected. But When playback by GStreamer, I control media output by Qt. Output will scale full screen after that I call GUI control play,stop, trick play...So when this GUI appear, I think it is in behind of media output so I need click first time to make focus on GUI and one more to trigger action.
        => Do you understand what I say and do you have any solution for this case ?
        Or may be it is bug of Wayland because output is shown on wayland Platform.

      Thank you

      A 1 Reply Last reply 7 Apr 2017, 22:33
      0
      • H Hung Tran
        7 Apr 2017, 07:34

        @ambershark

        Wow, It's difficult to explain to you. But I have short information to you:

        1. I use Qt for GUI that control action of player. And use GStreamer for playback. Don't playback by qt because qt can't control hardward as my expected.
        2. GUI action will call API of GStreamer.
        3. Before playback by Gstreamer, GUI action as expected. But When playback by GStreamer, I control media output by Qt. Output will scale full screen after that I call GUI control play,stop, trick play...So when this GUI appear, I think it is in behind of media output so I need click first time to make focus on GUI and one more to trigger action.
          => Do you understand what I say and do you have any solution for this case ?
          Or may be it is bug of Wayland because output is shown on wayland Platform.

        Thank you

        A Offline
        A Offline
        ambershark
        wrote on 7 Apr 2017, 22:33 last edited by
        #10

        @Hung-Tran Ok yea I get it now. You explained it very well.

        My guess based on what you said is that it is a problem with how you get focus to a window in your window manager.

        Which window manager are you using? Most can be set to activate and pass mouse click, or just activate window on click, etc.

        So with that in mind a quick test to see if you are having a "focus click" then "activate" click is to click somewhere else in that GUI window that pops up. This will focus it. Then click your button to activate. If it works with 1 click then focus is your issue. If not there may be something deeper going on.

        Either way with a bit more info I might be able to suggest some possible fixes.

        Also, quick note on wayland.. In my opinion there are still a lot of problems with wayland. I just don't feel it's ready for prime time yet. This could definitely be a problem related to wayland, but you can always test on xorg or something to see if the problem goes away. That would let you know if it's a wayland issue or not.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        H 2 Replies Last reply 10 Apr 2017, 03:44
        1
        • A ambershark
          7 Apr 2017, 22:33

          @Hung-Tran Ok yea I get it now. You explained it very well.

          My guess based on what you said is that it is a problem with how you get focus to a window in your window manager.

          Which window manager are you using? Most can be set to activate and pass mouse click, or just activate window on click, etc.

          So with that in mind a quick test to see if you are having a "focus click" then "activate" click is to click somewhere else in that GUI window that pops up. This will focus it. Then click your button to activate. If it works with 1 click then focus is your issue. If not there may be something deeper going on.

          Either way with a bit more info I might be able to suggest some possible fixes.

          Also, quick note on wayland.. In my opinion there are still a lot of problems with wayland. I just don't feel it's ready for prime time yet. This could definitely be a problem related to wayland, but you can always test on xorg or something to see if the problem goes away. That would let you know if it's a wayland issue or not.

          H Offline
          H Offline
          Hung Tran
          wrote on 10 Apr 2017, 03:44 last edited by
          #11

          @ambershark

          This is my process:

          1. App run, QMainWindow show QWidget myMainUi
          2. on myUi have Open button, when click Open button then QFileDialog appear ( I want QDialog appear on middle screen so I create new QWidget *openfileContainerwith full screen that contain QFileDialog).
          3. After i select video file (QFileDialog close native) and I hide openfileContainer:
          myMainUi->hide();
          
          	if (!openfileContainer) {
          		openfileContainer = new QWidget();
          	}
          
          	openfileContainer->setStyleSheet("background: black;");
          	openfileContainer->move(0, 0);
          	openfileContainer->resize(1920, 1080);
          	openfileContainer->show();
          
          	QFileDialog* dialog = new QFileDialog(openfileContainer);
          	dialog->setStyleSheet("background: #eee;");
          	dialog->setFileMode(QFileDialog::ExistingFile);
          	dialog->setNameFilter(QObject::tr("Clip (*.mkv *.avi *.mp4 *.divx)"));
          	dialog->setViewMode(QFileDialog::Detail);
          	dialog->setOption(QFileDialog::DontUseNativeDialog);
          	dialog->setDirectory(QObject::tr("/home/root/video"));
          
          	res = dialog->exec();
          	openfileContainer->resize(0, 0);
          	openfileContainer->hide();
          
          
          	myMainUi->show();
          

          after that I show myMainUi;

          myMainUi->show();
          
          1. Play video
                          this->myState.setState(DivXPlayerState::APP_STATE_PLAY);
          
          		sleep(2);
          		myMainUi->hide();
          		myMainUi->show();
          

          From now, I don't know why APP can not focus to myMainUi after I show it. I tried to set APP focus on myMainUi but it does not work.

          		this->myState.setState(DivXPlayerState::APP_STATE_PLAY);
          
          		sleep(2);
          		myMainUi->hide();
          		myMainUi->show();
          		//new code
          		myMainUi->setFocusPolicy(Qt::StrongFocus);
          		myMainUi->setFocus();
          

          Do you have any solution for this case?

          1 Reply Last reply
          0
          • A ambershark
            7 Apr 2017, 22:33

            @Hung-Tran Ok yea I get it now. You explained it very well.

            My guess based on what you said is that it is a problem with how you get focus to a window in your window manager.

            Which window manager are you using? Most can be set to activate and pass mouse click, or just activate window on click, etc.

            So with that in mind a quick test to see if you are having a "focus click" then "activate" click is to click somewhere else in that GUI window that pops up. This will focus it. Then click your button to activate. If it works with 1 click then focus is your issue. If not there may be something deeper going on.

            Either way with a bit more info I might be able to suggest some possible fixes.

            Also, quick note on wayland.. In my opinion there are still a lot of problems with wayland. I just don't feel it's ready for prime time yet. This could definitely be a problem related to wayland, but you can always test on xorg or something to see if the problem goes away. That would let you know if it's a wayland issue or not.

            H Offline
            H Offline
            Hung Tran
            wrote on 10 Apr 2017, 08:11 last edited by
            #12

            @ambershark I also have concern about:

            When I call:

            gst_element_set_state(myPipeLine, GST_STATE_PLAYING);
            

            It means APP playback by GStreamer and media output set full screen.
            After that, I show myMainUi so I think media output overlay UI of APP because Media Output is independent with UI of app. If it is reason, how I can fix it ?

            A 1 Reply Last reply 11 Apr 2017, 02:33
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 10 Apr 2017, 21:00 last edited by
              #13

              Hi,

              Since you seem to be using low-level GStreamer code then you should consider the QtGStreamer module.

              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
              2
              • H Hung Tran
                10 Apr 2017, 08:11

                @ambershark I also have concern about:

                When I call:

                gst_element_set_state(myPipeLine, GST_STATE_PLAYING);
                

                It means APP playback by GStreamer and media output set full screen.
                After that, I show myMainUi so I think media output overlay UI of APP because Media Output is independent with UI of app. If it is reason, how I can fix it ?

                A Offline
                A Offline
                ambershark
                wrote on 11 Apr 2017, 02:33 last edited by
                #14

                @Hung-Tran Well the problem here is getting focus to your window. When gstreamer takes over you lose focus.

                I don't think you can get focus back in linux without user intervention. It's been a while since I tested this so you can try and find out.

                The calls you need to attempt to gain focus are activateWindow() and raise() both are part of QWidget.

                Like I said though, no guarantee that you will get focus. That is up to the window manager and most these days prevent applications from "stealing" focus without user interaction. This is true in Windows and OSX as well.

                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                H 1 Reply Last reply 11 Apr 2017, 07:42
                1
                • A ambershark
                  11 Apr 2017, 02:33

                  @Hung-Tran Well the problem here is getting focus to your window. When gstreamer takes over you lose focus.

                  I don't think you can get focus back in linux without user intervention. It's been a while since I tested this so you can try and find out.

                  The calls you need to attempt to gain focus are activateWindow() and raise() both are part of QWidget.

                  Like I said though, no guarantee that you will get focus. That is up to the window manager and most these days prevent applications from "stealing" focus without user interaction. This is true in Windows and OSX as well.

                  H Offline
                  H Offline
                  Hung Tran
                  wrote on 11 Apr 2017, 07:42 last edited by
                  #15

                  @ambershark I have a question:
                  How to know where mouse focus on when app running ?
                  I'm trying get focus to control UI but I have no luck. So I want to check when app change state, where mouse focus on.

                  A 1 Reply Last reply 11 Apr 2017, 21:43
                  0
                  • H Hung Tran
                    11 Apr 2017, 07:42

                    @ambershark I have a question:
                    How to know where mouse focus on when app running ?
                    I'm trying get focus to control UI but I have no luck. So I want to check when app change state, where mouse focus on.

                    A Offline
                    A Offline
                    ambershark
                    wrote on 11 Apr 2017, 21:43 last edited by
                    #16

                    @Hung-Tran That is something you will need to do specific to each OS. There is no way to do it with Qt (that I'm aware of).

                    For instance, here is how you would do it with X11 http://stackoverflow.com/questions/1014822/how-to-know-which-window-has-focus-and-how-to-change-it.

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    H 1 Reply Last reply 18 Apr 2017, 09:11
                    1
                    • A ambershark
                      11 Apr 2017, 21:43

                      @Hung-Tran That is something you will need to do specific to each OS. There is no way to do it with Qt (that I'm aware of).

                      For instance, here is how you would do it with X11 http://stackoverflow.com/questions/1014822/how-to-know-which-window-has-focus-and-how-to-change-it.

                      H Offline
                      H Offline
                      Hung Tran
                      wrote on 18 Apr 2017, 09:11 last edited by
                      #17

                      @ambershark Sry for late reply.

                      In my case, I finally uses code C to create fake clicking on UI to active UI. I can't solve this issue by Qt5 so I have no choose for this issues. It's not my expected but It can make my APP better than.

                      1 Reply Last reply
                      1

                      17/17

                      18 Apr 2017, 09:11

                      • Login

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