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

Author Topic: Getting input for a sfml window embedded in qt application  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

jmaclives

  • Newbie
  • *
  • Posts: 2
    • View Profile
Getting input for a sfml window embedded in qt application
« on: October 04, 2012, 11:56:22 pm »
Hey all,
I am currently learning sfml 1.6/2.0 (which is amazing btw).  I've spent the last week or so developing a pretty cool (for my level ha) 2d tile map engine with working camera, zoom etc, and this loads a txt file to do all the rendering bla bla bla...

Anyways, I want to make an editor in Qt so that I dont need to make boring txt files all day.  I created a  QWidget/sf::RenderWindow extension (kind of like the qt tutorial), and moved the 'main loop' to the OnUpdate() function.  This prints out the initial screen fine, but I can't get inputs to register with the window.  The screen still refreshes, ( if I just have something move (without input) it will still do so), its just my original input code isn't registering.  Is there any trick here that is obvious?  I setFocusPolicy(Qt::StrongFocus).

I can show code if necessary, just wondering if anyone hit this same roadblock.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: Getting input for a sfml window embedded in qt application
« Reply #1 on: October 05, 2012, 06:16:31 am »
I can't think of anything without seeing he code. It's all about reimplementing QWidget::mousePressEvent(), mouseMoveEvent() and mouseReleaseEvent() and pass the position to the SFML window.

jmaclives

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Getting input for a sfml window embedded in qt application
« Reply #2 on: October 05, 2012, 07:32:26 am »
Hey thanks man for replying.  It makes since that I would need to utilize the Qt input methods.
I don't have access to my code until tomorrow, so if this is still an issue tomorrow i'll post it.

What I did is just port the SFML input methods to the Qt OnUpdate() method, I guess it doesn't get through, still trying to figure out how the two interact  :-\
So in the OnUpdate() I have a if (sf::Keyboard:: blah blah to check for input and adjust accordingly.

I'll mess with connecting the Qt signals to my graphics window tomorrow, let everyone know how it goes.