Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - daijin12

Pages: [1]
1
Hello everyone,

I have a problem to integrate a SFML renderwindow inside a Qt widget, since the new SFML 2.4 is released.
The problem happens only on my linux (on windows everything's fine).

My config :
 - Ubuntu 16.04
 - Qt 5.7.0
 - gcc 6.1.1 (tried with 5.3 and 4.9)
 - SFML 2.4 from github up to date

It seems that sf::RenderWindow::create(winId());  "create" an infinite loop...
The result is a Qt widget with a transparent inside...

Looking a bit more inside the SFML code, it appears that it comes from the lines 927 and 928 of the file src/SFML/Window/Unix/WindowImplX11.cpp in the function setVisible(bool visible):

void WindowImplX11::setVisible(bool visible)
{
    if (visible)
    {
        .........
        .........

        // Before continuing, make sure the WM has
        // internally marked the window as viewable
        while (!m_windowMapped)
            processEvents();
    }
 


Removing this while loop solves the problem.

I put in attachments a simplest code reproducing the bug.

If you've any idea of what's going on, please let me now.

Cheers,
daijin12


2
Window / [Solved] [Qt5+SFML2.1] Resizing a SFML canvas in a QLayout
« on: November 28, 2013, 02:42:38 am »
Hello everyone,

I have a problem in a program using SFML 2.1 integrated in a Qt5 interface.
I placed the QSFMLCanvas in the layout of a QStackedWidget itself inserted into the centralwidget of a QMainWindow:
 
Sfml = new QSFMLCanvas(this);
   
widget_container = new QStackedWidget(this);
widget_container->addWidget(Sfml);
widget_container->setCurrentWidget(Sfml);
widget_container->layout()->setAlignment(widget_container,Qt::AlignCenter);
setCentralWidget(widget_container);
 

It works fine under Linux (Fedora 18), the canvas is well resized with the QMainWindow.

By cons, under Windows 7, the canvas keeps it original size and is positioned at the bottom left when you resize the QMainWindow.

I tried to see what was happening by printing the size of the QWidget and of the RenderWindow which are the parent classes of QSFMLCanvas in the resizeEvent() function:
void QSFMLCanvas::resizeEvent(QResizeEvent *event)
{
    std::cout << size().width() <<" " << size().height()
              <<  " " << getSize().x << " " << getSize().y <<  std::endl;
}
 

and here is an example of the output:
815 639 700 579
815 639 700 579
825 641 700 579
825 641 700 579
835 644 700 579
835 644 700 579
842 646 700 579

RenderWindow size does not vary while the QWidget is well resized.

I tried to add a setSize() in the resizeEvent() function but it does not change anything:
void QSFMLCanvas::resizeEvent(QResizeEvent *event)
{
    setSize(sf::Vector2u(event->size().width(),event->size().height()));
   
        std::cout << size().width() <<" " << size().height()
              <<  " " << getSize().x << " " << getSize().y <<  std::endl;
}
 

If someone has an idea to fix that, it would help me a lot.

Thank you in advance and sorry if my english is bad,

daijin12

Pages: [1]