0

I have a problem with a Qt dialog customization. The dialog contains an image (QLabel with pixmap) and under a panel with buttons on it. By default the dialog has no title bar and border and the panel is not visible. When I click on the displayed image, the panel became visible and the border should be also visible in order to the user could resize the dialog.

Setting the panel visible, or invisible is easy and hide the border at the beginning is also clear:

setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );

BUT

I'm not able to restore the border of the window. I've tried this:

// this is in the header

Qt::WindowFlags m_wndFlags;

// this is in the cpp

dlgImageWindow::dlgImageWindow()
{
   Qt::WindowFlags m_wndFlags = windowFlags();

   setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );
}

... // border is hidden

void dlgImageWindow::_showBorder()
{
  setWindowFlags( m_wndFlags );
}

Unfortunatelly the result is that the whole dialog disappears. Any idea?

bukkfa
  • 373
  • 3
  • 9
  • Actually my problem solved with adding 'show();' line after the 'setWindowFlags...' procedure. I don't know why the setWindowFlags hide the entire window, but it does. Actually the above code can restore the border as expected and with the show procedure the window remain visible. – bukkfa Aug 12 '14 at 19:34
  • possible duplicate of [setWindowFlags(Qt::WindowStaysOnTopHint) hides Qt Window](http://stackoverflow.com/questions/19097323/setwindowflagsqtwindowstaysontophint-hides-qt-window) – timday Aug 12 '14 at 20:31
  • Yeppp ... thanks timday! "This function calls setParent() when changing the flags for a window, causing the widget to be hidden. You must call show() to make the widget visible again.." – bukkfa Aug 12 '14 at 21:16

2 Answers2

0

it might be because you use

Qt::WindowFlags m_wndFlags = windowFlags();

which assigns the current window flags to a locale variable and the this->m_wndFlags never gets set correct

Zaiborg
  • 2,492
  • 19
  • 28
0

Zaiborg: thanks for your answer. Actually the code above is a bit simplified and just for reference to the real code.

The problem was that the window disappeared when I used the setWindowFlags() procedure.

In the comments 'timday' linked another session where similar issue raised and solved by calling the show() procedure just after the setWindowFlags().

After I used the show() procedure it is figured out that my process worked per spec.

bukkfa
  • 373
  • 3
  • 9