Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fullscreen button for ImageDisplay #1802

Closed
ClementLeBihan opened this issue Sep 15, 2023 · 4 comments
Closed

Fullscreen button for ImageDisplay #1802

ClementLeBihan opened this issue Sep 15, 2023 · 4 comments

Comments

@ClementLeBihan
Copy link

Hi !
I'm trying to add a fullscreen button for ImageDisplay, without success.
I think it could be a good feature.

I've created a fullscreen button in the titlebar of the widget :

QToolButton* fullscreen_button = new QToolButton();

  fullscreen_button->setText("FullScreen");
  fullscreen_button->setIconSize(QSize(10, 10));

  connect(fullscreen_button, SIGNAL(clicked()), this, SLOT(updateFullScreen()));

  dynamic_cast<QHBoxLayout*>(getAssociatedWidgetPanel()->titleBarWidget()->layout())
      ->insertWidget(2, fullscreen_button);

and implemented the updateFullScreen function :

void ImageDisplay::updateFullScreen()
{
  if (!(getAssociatedWidgetPanel()->windowState() & Qt::WindowFullScreen)) {
    getAssociatedWidgetPanel()->setFloating(
        true);
    getAssociatedWidgetPanel()->showFullScreen();
  } else {
    getAssociatedWidgetPanel()->setFloating(false);
    getAssociatedWidgetPanel()->showNormal();
  }
}

Unfortunately, something weird happen.
The first time I click, the widget start floating but not fullscreen.
The second time I click, the widget doesn't move
The third time I click, the widget stop floating
The Fourth time I click, the widget goes fullscreen as expected.

Do you have an idea why It needs 4 clicks ?
I have no idea how QtWidget works, I may forgot to call a function ...

Thank you for your help,
Best regards,
Clément

@rhaschke
Copy link
Contributor

I'm afraid that is a Qt limitation. See the corresponding note in the docs.
Maximizing the window works as expected: #1803
Note that you should remember the previous state of the display (floating or not) and restore that state.

@ClementLeBihan
Copy link
Author

In my side maximizing also need 4 clicks before beeing maximized. But there is the same warning about maximizing. Thank you for giving me the link, I wasn't aware of the limitation.

It says On X11, a window does not have a frame until the window manager decorates it. This happens asynchronously at some point in time after calling [QWidget::show](https://doc.qt.io/qt-5/qwidget.html#show)() and the first paint event the window receives, or it does not happen at all. It seems to correspond the fact that I need to click 4 times on my button to see window maximizing or fullscreening.

Thanks a lot for your quick answer and for your help @rhaschke !!!

@rhaschke
Copy link
Contributor

On my side maximizing also needs 4 clicks before being maximized.

I was using Qt 5.15 on Ubuntu Jammy. Maybe on Focal with Qt 5.12 it doesn't (yet) work?

@ClementLeBihan
Copy link
Author

That's may be the point ! Thank you @rhaschke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants