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. How to hide the current window and then cut screen.
Forum Updated to NodeBB v4.3 + New Features

How to hide the current window and then cut screen.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.8k 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.
  • L Offline
    L Offline
    lingyun9833
    wrote on 12 Oct 2013, 09:31 last edited by
    #1

    Hi everyone!

    I'm a new member of forum and I'm a beginner with Qt. I searched in forum if somebody else had the same problem, but there is no such result.

    My problem is the following:
    (1) I want to cut screen after this windows has hidden, but sometimes the windows has not hide completed.
    Delay 10 millisecond is a temporary solution, but sometimes this problem reappear. Is there a better way that can hide the window exactly ?
    (2) The ScreenCutDialog can not get Focus because the current window is minimized, when the last active window is belonged to other programs, cause that no-responsey when press "ESC" key . Is there any Solution?

    I have tried a lot of methods, but no results, thank you. Best regards !
    @
    void CChatInput::slot_OnSnap()
    {
    if(isSnapHide()) // if true, this window should minimize before cut screen
    {
    slot_minimizeDialog(); // hide the dialog
    //QEventLoop eventLoop;
    //QTimer::singleShot(10,&eventLoop,SLOT(quit())); //delay 10 millisecond
    //eventLoop.exec();
    }
    cutScreen();
    slot_activeDialog(); //active the parent window
    }

    void CChatInput::cutScreen()
    {
    ScreenCutDialog dlg; //
    if (dlg.exec() == QDialog::Accepted)
    {
    //... ...
    }
    }

    void CChatInput::slot_minimizeDialog()
    {
    QWidget* ppp = CommonFun::getTopParentWidget(this); // get current window

    if (ppp!=NULL)
    {
    ppp->showMinimized();
    }
    }
    @
    @
    void ScreenCutDialog::keyPressEvent(QKeyEvent *event)
    {
    QDialog::keyPressEvent(event);
    if (event->key() == Qt::Key_Escape)
    {
    reject();
    }
    }@

    As a tree, I have my own posture.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mehrdadsilver
      wrote on 12 Oct 2013, 11:00 last edited by
      #2

      I think you can use @ void QWidget::hideEvent(QHideEvent * event) @ to detect when window is hidden. rewrite this function and cut window here.

      Mehrdad Abdolghafari, Be silver

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lingyun9833
        wrote on 13 Oct 2013, 11:20 last edited by
        #3

        Thank you, I tried this way before I asked in this Forum, but didn't work. The Area that hasn't hidden is the part overlap other windows. It means that, the windows hasn't hidden completely, and the ScreenCutDialog can cut the part that overlap other windows.

        As a tree, I have my own posture.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lingyun9833
          wrote on 13 Oct 2013, 11:30 last edited by
          #4

          Thank you, I tried this way before I asked in this Forum, but didn’t work. The Area that hasn’t hidden is the part overlap other windows. It means that, the windows hasn’t hidden completely, and the ScreenCutDialog can cut the part that overlap other windows.
          [quote author="mehrdadsilver" date="1381575639"]I think you can use @ void QWidget::hideEvent(QHideEvent * event) @ to detect when window is hidden. rewrite this function and cut window here.[/quote]

          As a tree, I have my own posture.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lingyun9833
            wrote on 8 Nov 2013, 08:53 last edited by
            #5

            Thanks for mehrdadsilver . The second problem that no-responsey when press “ESC” key hava solved. I use activeWindow() to make the ScreenCutDialog hava focus. I use the way that Delay 50 millisecond as a temporary solution to reduce the probability of window hidden endless.

            As a tree, I have my own posture.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tilsitt
              wrote on 8 Nov 2013, 09:14 last edited by
              #6

              Hi,

              instead of minimizing your window, why don't you use "QWidget::hide()":http://qt-project.org/doc/qt-5.1/qtwidgets/qwidget.html#hide?

              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