Results 1 to 3 of 3

Thread: problem in widget inheritance

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question problem in widget inheritance

    i created one object "main" with stackedwidget where there is four pages and in four pages i create three "panel" classes
    Qt Code:
    1. MainWindow ::MainWindow(QDialog *parent)
    2. {
    3. Panel *panel = new Panel();
    4. }
    To copy to clipboard, switch view to plain text mode 
    now in panel.cpp a Qpushbutton "control" ... if i click the pushbutton of panel class can i change the page of the main class stackedWidget
    i am having less C++ knowledge
    please help
    Last edited by jpn; 11th December 2008 at 16:30. Reason: missing [code] tags

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem in widget inheritance

    Give us more code.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: problem in widget inheritance

    in program
    mainwindow.cpp
    designer: mainwindow.ui--> Qstackedwidget having pages 4;
    in each page a 'frame' say frame1, frame 2,frame 3, frame 4;
    beside the stacked widget three 'pushbutton' say pButton1,pButton2,pButton3
    so constructing
    Qt Code:
    1. class MainWindow : public QDialog, public Ui::MainWindow
    2. setupUi(this) ;
    3.  
    4. connect(pButton1 , SIGNAL(clicked()), this, SLOT(nextPage1()));
    5. void MainWindow::nextPage1()
    6. {
    7. stackedWidget->setCurrentIndex(0);
    8. }
    9.  
    10. connect(pButton2 , SIGNAL(clicked()), this, SLOT(nextPage2()));
    11. void MainWindow::nextPage2()
    12. {
    13. stackedWidget->setCurrentIndex(1);
    14. }
    15.  
    16. connect(pButton1 , SIGNAL(clicked()), this, SLOT(nextPage3()));
    17. void MainWindow::nextPage3()
    18. {
    19. stackedWidget->setCurrentIndex(4);
    20. }
    21.  
    22. /*so if we click the three buttons the stack widget will change the pages - right!*/
    To copy to clipboard, switch view to plain text mode 

    now
    in same mainwindow.cpp
    Qt Code:
    1. #include "panel.h" /* an external program */
    2. Panel *panel = new Panel();
    3.  
    4. QVBoxLayout *layout = new QVBoxLayout;
    5. layout->addWidget(panel);
    6. frame1->setLayout(layoout);
    7. /*[I]so now the panel will be loaded to the page 1 --right![/I] * /
    To copy to clipboard, switch view to plain text mode 

    this is the setup in mainwindow.cpp program

    in panel.cpp
    designer: subwindow.ui ->three pushbuttons say subButton1,subButton2,subButton3
    so constricting
    Qt Code:
    1. class Panel2 : public QDialog, public Ui::SubWindow
    2. setupUi(this)
    To copy to clipboard, switch view to plain text mode 


    this is my program looks like
    in mainwindow
    clicking pButton1->stackedWidget->page1
    clicking pButton2->stackedWidget->page2
    clicking pButton3->stackedWidget->page3

    now i want
    in panel
    clicking subButton1->stackedWidget(mainwindow's)->page4
    that is i have to change the mainwindow's stackedwidget page from clicking panel's subButton1

    this is my problem how can i solve it "please help me"
    Last edited by jpn; 11th December 2008 at 16:34. Reason: missing [code] tags

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 20:39
  3. Widget resizing problem
    By fwohlfert in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2006, 08:16
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16
  5. Replies: 7
    Last Post: 3rd February 2006, 10:20

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.