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

Author Topic: opening an SFML and a QT window in the same time  (Read 1409 times)

0 Members and 1 Guest are viewing this topic.

Argetlams

  • Newbie
  • *
  • Posts: 2
    • View Profile
opening an SFML and a QT window in the same time
« on: April 01, 2014, 06:09:01 pm »
Hi everybody

I 'm pretty new in coding C++ and i use QT creator , i created a QT window with a button. when it is clicked on it is supposed to open an SFML window. 

no mistakes in compilation , however when the sfml window pop up, the application slow down drastically, also when i click on anything it instantly crash.

so i guess adding an sfml window with a QT window is not that easy, is it even possible ?

here is the code just in case the mistake is from me :
bool MainWindow::InkJetFlush()
{
    int IntCountDown(10);
    string TxtCountDown("10");
    Clock ClTimer;
    Time TimeClock;
    int32 TimeInt;
    float AngleRotation;
    Color BackGroudColor = Color::White;


     RenderWindow WindFlushTimer(VideoMode(300, 300), "Flush");
     Texture TxtNeedle;
     Texture TxtClock;

     if (!TxtNeedle.loadFromFile("ClockNeedle.png"))
     {
             return false;
     }
     Sprite SpNeedle(TxtNeedle);
     SpNeedle.setOrigin(56, 9);
     SpNeedle.rotate(270);
     SpNeedle.setPosition(150, 150);

     if (!TxtClock.loadFromFile("C:/Aprojects/InkJetProject/Clock_cadran.png"))
     {
             return false;
     }
     Sprite SpClock(TxtClock);
     SpClock.setPosition(50, 50);

     Font FoCountDown;
     if (!FoCountDown.loadFromFile("C:/Aprojects/InkJetProject/arial.ttf"))
            return false;

        Text TextCountDown(TxtCountDown, FoCountDown, 90);



    while (WindFlushTimer.isOpen())
    {
        Event TimerEv;

        WindFlushTimer.clear(BackGroudColor);

        WindFlushTimer.draw(SpNeedle);
        WindFlushTimer.draw(SpClock);
        WindFlushTimer.draw(TextCountDown);

        WindFlushTimer.display();
        TimeClock = ClTimer.getElapsedTime();

            if (TimeClock.asSeconds() == 1)
            {
                TextCountDown.setString("9");
                SpNeedle.rotate(AngleRotation);

                if (TimeClock.asSeconds() == 10)
                {
                    WindFlushTimer.close();
                }

            }






    }

    return true;

}

 

PS : as i said i'm new in c++ so i'm sure you will find a lot of thing i did the wrong way, sorry about that, also my english is far from perfect.

Argetlams

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: opening an SFML and a QT window in the same time
« Reply #1 on: April 03, 2014, 03:35:44 pm »
up ! really need help here :(

eike

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: opening an SFML and a QT window in the same time
« Reply #2 on: April 05, 2014, 10:12:54 am »
Hi!

Side Note: You can do similar things with QT, so you don't need SFML for this.

Could you simplify the example a little bit and provide an event-loop like

while(window.isOpen())
{
        sf::Event event;
        while(window.pollEvent(event))
        {
...
 

 

anything