Qt questions

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Kyosaur
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Tue Jul 13, 2010 2:00 am
Favorite Gaming Platforms: PS2,PS3,NDS
Programming Language of Choice: C++

Qt questions

Post by Kyosaur »

Warning: the following post might contain: noobie questions, stupidity, secrets to the universe, and confusion. Readers discretion is advised.

I recently jumped balls deep into Qt and converted one of my old applications to use this fantastic library. I successfully converted the core (this was extremely enjoyable and actually cut the code down drastically), but im having some issues with the UI side of things. This application has a lot of widgets and menu items involved, so i decided to try out Qt's creator instead of building it completely by hand; im more than capable of doing this as i did it once already (Win32 API), it would just take a huge amount of time (as apposed to 5 minutes in the creator).

I built the UI using the creator and im pretty content with it, hell i even upgraded the look since i dont have to build it by hand, the only problem that i can see is handling events. I've read all about the signal and slots mechanism and also some stuff pertaining to events. The signal/slot editor is of no use to me at all as it only does trivial things like pasting text from the clipboard to a QPlainTextEdit widget, or closing the application when a button is pressed. What im looking to do is a bit more advanced (well at the very least, wont suffice with basic general instructions like copy/paste). Here's what my application needs to do (i have the core and the UI form all done, just gotta link them):
  • A user presses a button (convert button).
    • Fetch text from a QPlainTextEdit and store it in a QString.
      • Create a "Convert" object (no default ctor- it takes a QString containing data to convert, and gets it ready for parsing).
      • Fetch options related to the parse (QRadioButtons/Menu items).
      • Call my parse member function passing said options as parameters. This returns a QString object containing the new format that was converted.
      • Set the main QPlainTextEdit's text using the newly formatted data.
This is pretty much the basics of what my application does. How can i make this a reality? As far as i know signal and slots wont fit my needs, so what should i do? Using event related stuff seems to require access to code that i simply do not have (the UI related stuff seems to be located in an XML file, sadly).

If i cant do this using the Qt creator, why the hell does it even exist? I like that it saves TONS of time when creating advanced UI's, but i kind of need my program to...well...function!

So, do i need to write this UI by hand? If so, thats kind of a downer lol. Any help is appreciated (im new to Qt, and i cant really find much stuff relating to this topic (well using the creator)).
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Qt questions

Post by Falco Girgis »

kyosaur wrote: As far as i know signal and slots wont fit my needs, so what should i do?
Dude, signals and slots fit EVERY need in QT. Your problem is solved with the simplest form of a single signal/slot connection.

Of course you don't need to write that UI by hand. You need to write that slot by hand (OnClick()) and connect it to the QPushButton's OnClick() signal through the signal/slots editor. Boom, simple as that.
User avatar
Kyosaur
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Tue Jul 13, 2010 2:00 am
Favorite Gaming Platforms: PS2,PS3,NDS
Programming Language of Choice: C++

Re: Qt questions

Post by Kyosaur »

GyroVorbis wrote:
kyosaur wrote: As far as i know signal and slots wont fit my needs, so what should i do?
Dude, signals and slots fit EVERY need in QT. Your problem is solved with the simplest form of a single signal/slot connection.

Of course you don't need to write that UI by hand. You need to write that slot by hand (OnClick()) and connect it to the QPushButton's OnClick() signal through the signal/slots editor. Boom, simple as that.
That is great news! I've never seen this before to be honest so i'll have to do some reading (it kind of sucks being a complete noob when it comes to a new library). Any time i see someone using the signals and slots mechanism they're either completely coding everything by hand, or they use the the editor and using the "pre-made" (for lack of better terminology) signals-never touching a bit of code :(. Thats what made me confused :\.

Thanks for the answer man.
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Qt questions

Post by Falco Girgis »

Kyosaur wrote:
GyroVorbis wrote:
kyosaur wrote: As far as i know signal and slots wont fit my needs, so what should i do?
Dude, signals and slots fit EVERY need in QT. Your problem is solved with the simplest form of a single signal/slot connection.

Of course you don't need to write that UI by hand. You need to write that slot by hand (OnClick()) and connect it to the QPushButton's OnClick() signal through the signal/slots editor. Boom, simple as that.
That is great news! I've never seen this before to be honest so i'll have to do some reading (it kind of sucks being a complete noob when it comes to a new library). Any time i see someone using the signals and slots mechanism they're either completely coding everything by hand, or they use the the editor and using the "pre-made" (for lack of better terminology) signals-never touching a bit of code :(. Thats what made me confused :\.

Thanks for the answer man.
I would have been more helpful and posted code/directions, but I was at work. And now I'm at work taking a shit in the stall with my iPad, so that doesn't help.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Qt questions

Post by k1net1k »

GyroVorbis wrote:
Kyosaur wrote:
GyroVorbis wrote:
kyosaur wrote: As far as i know signal and slots wont fit my needs, so what should i do?
Dude, signals and slots fit EVERY need in QT. Your problem is solved with the simplest form of a single signal/slot connection.

Of course you don't need to write that UI by hand. You need to write that slot by hand (OnClick()) and connect it to the QPushButton's OnClick() signal through the signal/slots editor. Boom, simple as that.
That is great news! I've never seen this before to be honest so i'll have to do some reading (it kind of sucks being a complete noob when it comes to a new library). Any time i see someone using the signals and slots mechanism they're either completely coding everything by hand, or they use the the editor and using the "pre-made" (for lack of better terminology) signals-never touching a bit of code :(. Thats what made me confused :\.

Thanks for the answer man.
I would have been more helpful and posted code/directions, but I was at work. And now I'm at work taking a shit in the stall with my iPad, so that doesn't help.
<wipe gesture joke>
User avatar
Kyosaur
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Tue Jul 13, 2010 2:00 am
Favorite Gaming Platforms: PS2,PS3,NDS
Programming Language of Choice: C++

Re: Qt questions

Post by Kyosaur »

GyroVorbis wrote:
Kyosaur wrote:
GyroVorbis wrote:
kyosaur wrote: As far as i know signal and slots wont fit my needs, so what should i do?
Dude, signals and slots fit EVERY need in QT. Your problem is solved with the simplest form of a single signal/slot connection.

Of course you don't need to write that UI by hand. You need to write that slot by hand (OnClick()) and connect it to the QPushButton's OnClick() signal through the signal/slots editor. Boom, simple as that.
That is great news! I've never seen this before to be honest so i'll have to do some reading (it kind of sucks being a complete noob when it comes to a new library). Any time i see someone using the signals and slots mechanism they're either completely coding everything by hand, or they use the the editor and using the "pre-made" (for lack of better terminology) signals-never touching a bit of code :(. Thats what made me confused :\.

Thanks for the answer man.
I would have been more helpful and posted code/directions, but I was at work. And now I'm at work taking a shit in the stall with my iPad, so that doesn't help.
Ah dude its all good, i actually stumbled my way through it luckily. Your answer was exactly what i needed- you clarified that i didnt have to write my UI by hand, that signal and slots would work for me, and that i could connect custom slots using the signal/slot editor :D. Thanks again for that.
Image
Post Reply