December 6, 2010

husban husban
Lab Rat
2 posts

How to link push button to another form

Page  
1

Hey people,
I am pretty new at Qt creator, I wonder how I can use the designer view to create a simple form with one single push button that links the form to another form. However, there is no such visual feature whereas you can add form to the project, what about multiforms project. I would appreciate a short guidance on how to create two forms and link them to each other using push button.
Thankx

22 replies

December 6, 2010

t3chNo t3chNo
Lab Rat
51 posts

Connect button’s clicked signal to a slot in designer form class. In that slot you can create new form.

December 6, 2010

QtK QtK
Gene Splicer
1140 posts

I too don’t have much experience using Qt Designer. But AFAIK there is a Signal Slot Editor which you can make use of and launch another form.

December 6, 2010

Volker Volker
Mad Scientist
5250 posts

Signal/slot connections can be setup Qt Designer (or designer mode of Qt Creator) only for widgets living in the same .ui file. If you want to connect signals of widgets in one .ui file to a slot in another .ui file or class you must call connect() manually in your source files.

December 6, 2010

Andre Andre
Mad Scientist
4667 posts

The Signal/Slot Editor will not let you connect signals and slots across forms, only inside one form.

The connection can not be made in Designer, AFAIK. You can make the connection easily in code though. QObject::connect takes two QObject* arguments you can use. You would usually make such a connection in some piece of initialization code, or a constructor. See QObject::connect() for more information.

 Signature 

Nokia Certified Qt Specialist.
Interested in Qt consultancy and job opportunities.

December 6, 2010

husban husban
Lab Rat
2 posts

That’s great except for the fact that I have not got a clue about your help. Having mentioned that I am new at this I am looking for the easiest method to link a push button to a form using the design mood, drag and drop thing, u know simple form with an action button that’s all. Please help.

December 6, 2010

Volker Volker
Mad Scientist
5250 posts

Did you read the Getting Started Programming with Qt [doc.qt.nokia.com] guide? It’s a very good start to get a feeling for these kind of things.

There are translations in various languages availbe, also. Have a look at this Wiki page [developer.qt.nokia.com] all of them listed.

December 6, 2010

infoctopus infoctopus
Ant Farmer
113 posts

I strongly suggest reading basics on Qt, at least topics in Assistant. Qt Creator is tool for making things easier if you know what really happens. It shouldn’t be a black box.

Also Qt Framework encourage a good programming style (unlike RADs, point-and-click and the program is ready)

 Signature 

Qt rulez

December 6, 2010

Andre Andre
Mad Scientist
4667 posts
husban wrote:
That’s great except for the fact that I have not got a clue about your help. Having mentioned that I am new at this I am looking for the easiest method to link a push button to a form using the design mood, drag and drop thing, u know simple form with an action button that’s all. Please help.

Sorry my tips were not helpful for you. Qt won’t allow you to do what you want without writing some actual code. If you want to do this with nothing but drag and drop, perhaps Qt is not for you. Designer can be a handy tool to help you get some things done, but it won’t write your applications for you. What you want is not possible in only Designer.

 Signature 

Nokia Certified Qt Specialist.
Interested in Qt consultancy and job opportunities.

December 6, 2010

infoctopus infoctopus
Ant Farmer
113 posts

As for me, I prefer creating UI by hands. It’s easier to make changes, if needed.

 Signature 

Qt rulez

December 6, 2010

husban husban
Lab Rat
2 posts

Thanks for the hint, so where to start then and where the code should be added. And it seems i can use this-> pointer to assign an action to the push button, I am very familiar with c++ but I am having a difficult time finding how and where to add the code, thanks again

December 6, 2010

Volker Volker
Mad Scientist
5250 posts

The Getting Started Programming with Qt I mentioned earlier is a good starting point. Also the docs on Designer [doc.qt.nokia.com] and in particular the chapter “Using a Designer UI File in Your Application”.

Try things with small sample applications and adapt to your actual project later on.

December 6, 2010

fcrochik fcrochik
Ant Farmer
517 posts

Make sure to check:

http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics

 Signature 

Certified Specialist & Qt Ambassador Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop… Qt everywhere!

December 7, 2010

disperso disperso
Ant Farmer
166 posts
husban wrote:
Thanks for the hint, so where to start then and where the code should be added. And it seems i can use this-> pointer to assign an action to the push button, I am very familiar with c++ but I am having a difficult time finding how and where to add the code, thanks again

Husban, unfortunately there is no quick answer that gives a solution to your problem. Qt is very easy to learn, really, but you have to learn a little bit first about signals and slots. It might seem a bummer a first, but are pretty simple, as slots are regular functions, but ones that can be executed when a signal is emitted. You probably have to write a slot that instantiates the second form and raises it, and connect() it to the clicked() signal from the push button.

As Andre explained you, the Qt Designer is not enough for doing what you want. Is helpful for creating individual dialogs or layouts, but not that much for linking different dialogs.

I would start with the documents mentioned. Good luck!

December 7, 2010

QtK QtK
Gene Splicer
1140 posts

A reference most of the Qt books is available here [qt.nokia.com].

December 24, 2010

gerasalus gerasalus
Lab Rat
2 posts

I’m reading all the replies and wondering… are these all nerds and geeks there? Coming from java and Android world, i find development for Nokia pretty painful. Even developing for iPhones objective c is much easier that getting information around here. Arguments “qt is not for you”, “encourages good programming style”. Are you reading what you are writing? It encourages me to spend my time for learning new stuff, when all i want is to deliver some kind of business value. No wonder Nokia lags soooo behind, and with attitudes around here, it wont get any closer.

nice holidays for you all :)

Page  
1

  ‹‹ How to install Qt Beta or RC versions      The only thing I want for Christmas is … a new Nokia Qt SDK with Qt 4.7 and QtMobility 1.1 ››

You must log in to post a reply. Not a member yet? Register here!