Results 1 to 6 of 6

Thread: QStackedWidget pass data between stacks and switch by pushbutton from the staks

  1. #1
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QStackedWidget pass data between stacks and switch by pushbutton from the staks

    Hello all,

    I am very New to QT and C++. I usually do work in PHP and Perl.

    I am trying to make a multi form app that will pass data between the forms.

    Example:
    FormStack: Has the QStackedWIdget
    Form1: has a 2 buttons and textbox when either button is clicked the Next stack should show and have the button that was clicked and text from the 1`st forms textbox
    Form2 has 2 buttons back and close and lable

    The best solution i found for QT was to use QStackedWidget but i cant seem to find a way to make the staks communicate and pass the data between each other except with a button that is on the formstack(the form that holds the QstackedWidget

    And for the life of me i cannot make the slots and signals work between forms or 2 windows. they seem to only work within the same form.

    Please help me i spent 2 days trying to find a solution on the forms or in teh qt samples but no luck so far.

    I have attached the sample code (a modified multiform i found on this form that is the base of my app)multiform_modified.zip

    Thank you very much for the help.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget pass data between stacks and switch by pushbutton from the staks

    Looks like you got some coding to do. The signal/slot editor in the designer isn't as powerful as just coding C++, but it can help to get you started. However, what you seem to want is some wizard-type behavior. Doesn't QWizard match your requirements? It already has a lot of the functionality you need.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStackedWidget pass data between stacks and switch by pushbutton from the staks

    Franz, Thank you for your answer as i mentioned i have never programmed in C or QT i am learning this as i go, but most of what i found were info using the QSTackedwidget. I will give the Wizard a shot and see how things go. and i thank you for the help offer i appropriate it alot :-) Do you use skype or icq? maybe we can chat sometimes.

  4. #4
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStackedWidget pass data between stacks and switch by pushbutton from the staks

    So i looked at QWizard and it does not serve my purpose i am posting the code with the slots that i made somehow i get no compile error but its not working please have a look. i am desperate :-( stacknew.zip


    So i have now main window having the stackedWidget and that has 2 forms form1 form2
    form 1 has 2 buttons pushButton1 and pushButton2 and a textbox form2 has a lable

    what i am trying to do is when the form loads and i type in textbox then click on pushButton1or pushButton2 frm 2 should come to view in stackedwidget and lable on for 2 will have data from textbox of form1 plus an identifier for which button was clicked.

  5. #5
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Cool Re: QStackedWidget pass data between stacks and switch by pushbutton from the staks

    First off, you have the concept of stacked widgets wrong....if you search this forum you can get the answers to most of your questions...for example look at this thread http://www.qtcentre.org/threads/3313...hlight=stacked. The widgets are placed on each page of the stacked widget, not separate forms for the stacked widget. I would strongly suggest getting a book on C++ and QT. But to help you out a bit, there are several ways to accomplish what you are looking for. In your main window, place the stacked widget, put the widgets that you want on each widget (change the "stack" by clicking on the arrow in the upper right corner of the stacked widget. Then you have to become familiar with signals and slots to navigate your forms or perform any action based on the users actions. In your case, one way is to right click on your button#1 and go to slots. Then click on the appropriate signal (clicked()). This will create the definition of your slot and you have to code in there what you want to do. All controls can be accessed by thier appropriate properties. I did a little down and dirty modification of your project as an example.
    stacknew.zip
    I hope this helps....I would get a book to help you understand and also search these forums...If you are a newbie, then your question probably has already been asked and answered.

  6. #6
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStackedWidget pass data between stacks and switch by pushbutton from the staks

    Thank you for your help i was able to use the stackedWidget correctly with your explanation :-) I am reading a C++ book and a C++ QT book but sadly i dont have enough info from them yet. thus this is serving as a learning experience as well.

    Thank you for all the help

Similar Threads

  1. Replies: 5
    Last Post: 1st March 2010, 15:55
  2. Switch blue and red
    By bryan in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 19th January 2010, 15:23
  3. Switch GUI language of Creator 1.3.0?!?
    By Tiansen in forum Qt Tools
    Replies: 5
    Last Post: 12th January 2010, 14:33
  4. Replies: 0
    Last Post: 11th November 2008, 15:36
  5. How to switch Qt4 version
    By vieraci in forum Installation and Deployment
    Replies: 1
    Last Post: 1st May 2007, 18:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.