Sunday, July 6th 2008, 7:15pm UTC+1

You are not logged in.

  • Login
  • Register

Posts: 5

Location: Windsor, Ontario, Canada

Occupation: I.T.

1

Friday, September 7th 2007, 5:27pm

connecting two forms

how do I connect two forms. I have my main.ui form and I have another form whatever.ui if I click ok on the main form I want the whatever.ui form to pop up how do I do this?

thank Nathan
  • Go to the top of the page

2

Thursday, September 13th 2007, 10:07am

RE: connecting two forms

1. Add form1 parameter to the constructor of form2
2. Pass "this" to form2 instance created in form1
3. Create a form variable of form1 in form2 to be assign the passed instance of forma.

on form parameters u can call hide() and show() functions up on requirement.
  • Go to the top of the page

seguprasad

Trainee

Posts: 103

Location: INDIA

Occupation: Developer

3

Thursday, September 27th 2007, 2:26pm

This little bit tricky to call another form, follow the steps below,

1. Button name on the main.ui is OK.
2. Create a slot in main class of main.h file as below,
public slots:
void on_OK_clicked();
3. Write the implementation for on_OK_clicked() as below
void main::on_OK_clicked()
{
4. Create object of whatever.ui (include whatever.h in this file)
5. Call show() or exec() of whatever object acordingly
}

It will work fine. Try this.
-Segu,
  • Go to the top of the page

4

Thursday, February 14th 2008, 5:13am

one small question

Thanks for replying to this problem :-) . I followed the instructions and could follow them but am stuck at a small problem.

I have a main form, on which I have an about button, which when pressed should display another form with text on it.

This is the snippet of code in the ui.h of the main form.
void mainform::openabout()
111 {
112 aboutform f;
113 //Show the about form
114 f.show();
115 }
aboutform.ui.h has
#include <qfile.h>
13
14 void aboutform::init()
15 {
16 //do nothing
17 }

in the pro file .ui files listed are mainform.ui aboutform.ui.
pro file has

TEMPLATE = app
2 LANGUAGE = C++
3
4 CONFIG += qt warn_on release
5
6 SOURCES += main.cpp
7
8 FORMS = mainform.ui aboutform.ui
9
10 unix {
11 UI_DIR = .ui
12 MOC_DIR = .moc
13 OBJECTS_DIR = .obj
14 }


I created the openabout slot by using the connection editor and when the about button is clicked the openabout function is executed. The code compiles fine, with qmake and make, but I don't see a binary for aboutform!! and so when I click the about button the second form does not show.

Is there some obvious mistake that I have committed. Do I have to separately compile aboutform?

Thanks in advance,
-A
  • Go to the top of the page

5

Friday, February 15th 2008, 6:30pm

a little help please

Guys, if someone can see a mistake in my code (attached in the previous post)...please help me out.

Thanks,
-A
  • Go to the top of the page

Rate this thread