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. [Solved]My dialog inside of my mainwindow is not working
Forum Updated to NodeBB v4.3 + New Features

[Solved]My dialog inside of my mainwindow is not working

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 3.0k 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.
  • P Offline
    P Offline
    Project try
    wrote on last edited by
    #1

    Hey , yesterday I opened a post:

    http://qt-project.org/forums/viewthread/42376/

    and the guy said that I should try creating a transparent window , and I did it , I included the project " the transparent window " to my current project which has the problem that I opened a post for.. anyways my other dialogs are working when I use show and other methods , but when I used this:

    @
    FrameLess=new FramelessWindow(this);
    FrameLess->exec(); // show() is not working
    @

    it works , only problem is it hides my mainwindow and it doesn't really show the background transparent window

    here's the code for the frameless window:

    @

    this->setStyleSheet("background:transparent");
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setWindowState(Qt::WindowFullScreen);

    @

    I only want it to show when I click any button " shows as a full screen transparent window that I can click anywhere in it without effecting the programs behind the window , I want it like a transparent wall :D

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Project try
      wrote on last edited by
      #2

      Well , I think I got it only problem as I said it doesn't show...

      I added mouse events where when I press the left mouse button I can select anywhere in the widget, the only problem which is annoying is:

      @
      this->setAttribute(Qt::WA_TranslucentBackground);
      @

      this is the function that lets the widget be transparent , but when I use it the widget shows in the bar below " where all programs that are open are there " but i can select anything in the screen , which means it's not showing on the screen ?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Project try
        wrote on last edited by
        #3

        I've tried everything :( , is there another method to do this ?

        I saw this but still no one have a solution:

        http://www.qtcentre.org/threads/53362-Qt5-Translucent-alpha-channel-problems

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          Here is how I created a transparent window that fly on top of all windows and allows me to grab an area of a desktop. The key is a Qt::ToolTip.
          I have found this idea somewhere but I don't have a link.
          It works for me on Linux, have not tried it on Windows or MacOSX.

          @
          SelectImage::SelectImage(QWidget parent)
          : QWidget(parent)
          , m_rubberBand(nullptr)
          {
          setAttribute(Qt::WA_TranslucentBackground, true);
          setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
          QDesktopWidget
          desktop = QApplication::desktop();
          resize(desktop->screenGeometry().size());
          setCursor(Qt::CrossCursor);
          }
          @

          Then I used the events from QRubberBand example and here is my mouseReleaseEvent
          @
          void SelectImage::mouseReleaseEvent(QMouseEvent *event)
          {
          m_close = event->pos();
          m_rubberBand->hide();
          QRect grabRect = QRect(m_open, m_close).normalized();
          m_pixmap = QPixmap::grabWindow(QApplication::desktop()->winId())
          .copy(grabRect);
          close();
          parentWidget()->show();
          }
          @

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Project try
            wrote on last edited by
            #5

            Still didn't work :(

            not sure if it needs to be a child of another widget ? but I think it won't work since I've tried yesterday " not your method , but the one that I've posted " but still didn't work.

            the window doesn't show/display , it's like there's nothing , I can't use my events at all! but when I delete

            @
            this->setAttribute(Qt::WA_TranslucentBackground);
            @

            it works fine except it's not transparent.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #6

              Do you use style-sheets ? I think if you apply style-sheets then widgets behavior is different.
              If you building screen snapshot tool then there is another idea.

              • On start create a QPixmap from desktop
              • Create your "transparent" widget
              • Set background of the widget from the QPixmap.
              • Show new widget
              • Use QRubberBand to select area.
              • On mouseRelease close the widget.
              1 Reply Last reply
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

                [quote author="Project try" date="1399810333"]not sure if it needs to be a child of another widget ?[/quote]
                Yes transparent window is another QWidget that is shown on demand.
                I've used QWidget as parent class not QDialog.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Project try
                  wrote on last edited by
                  #8

                  Thanks , I actually thought of this yesterday , but never thought it would work , it actually worked doing what you've said , thanks so much ^^

                  but there's a little problem I think I'll make a new post about it since it's not related to this problem.

                  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