Results 1 to 9 of 9

Thread: QWidget on WidgetStack

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default QWidget on WidgetStack

    HI,
    i have designed a WidgetStack (with qtDesigner) with two page and I assinged them a name: page1 and page2 (this pages are QWidget, from desinger 'object explorer' I see this) .
    I'd like to do this:
    [code]
    Qt Code:
    1. QHBoxLayout *l = new QHBoxLayout(this->Page1);
    2. l->addWidget(myWidget3,0,0);
    3. this->WidgetStack->raiseWidget(Page1);
    To copy to clipboard, switch view to plain text mode 
    This don't work and MultipleView appear blank and mywidget3 appear in a small square on toolbar! Page2 is visible but I have insert on it a mywidget from designer...
    Why this?

    This below works but I'd like make different...
    Qt Code:
    1. WidgetStack->raiseWidget( myWidget3 );
    To copy to clipboard, switch view to plain text mode 
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget on WidgetStack

    Just use the addWidget method. There is not need to create any layouts.
    Qt Code:
    1. WidgetStack->addWidget(myWidget3, num);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QWidget on WidgetStack

    Sorry, but I need a layout....
    Regards

  4. #4
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QWidget on WidgetStack

    ...and I have also 2 widget in WidgetStack: page1 and page2; I'd like put a Hlayout on my page1 (QWidget create form designer) and insert inside Hlayout myWidget3....
    Any hints? I tried to put somthing on page1 (also only mywidget3) but without result....
    Any hints?
    Regards

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QWidget on WidgetStack

    Hi, I tried this but don't compile.
    I haven't still find a way to add a layoyut on 'MultupleView' (a page of a WidgetStack inserted from qtDesigner)
    Qt Code:
    1. //myMainForm constructor
    2. l = new QHBoxLayout(MultipleView);
    3. l->addWidget(myWidget3,0,0);
    4. MultipleView->setLayout(l);
    5. l->setAutoAdd(TRUE);
    6. WidgetStack->raiseWidget(MultipleView);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. mymainform.cpp(48): error C2248: 'QWidget::setLayout' : cannot access private member declared in class 'QWidget'
    To copy to clipboard, switch view to plain text mode 
    Any hints? Thank you..
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget on WidgetStack

    Quote Originally Posted by mickey
    Hi, I tried this but don't compile.
    I haven't still find a way to add a layoyut on 'MultupleView' (a page of a WidgetStack inserted from qtDesigner)
    Qt Code:
    1. //myMainForm constructor
    2. l = new QHBoxLayout(MultipleView);
    3. l->addWidget(myWidget3,0,0);
    4. MultipleView->setLayout(l);
    5. l->setAutoAdd(TRUE);
    6. WidgetStack->raiseWidget(MultipleView);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. mymainform.cpp(48): error C2248: 'QWidget::setLayout' : cannot access private member declared in class 'QWidget'
    To copy to clipboard, switch view to plain text mode 
    Any hints? Thank you..
    For some reason QWidgetStack the pagination begin with index 1
    Try like this:
    Qt Code:
    1. WidgetStack->addWidget(myWidget2);
    2. WidgetStack->addWidget(myWidget3);
    3. WidgetStack->raiseWidget(1);
    To copy to clipboard, switch view to plain text mode 
    There is no need to create layouts in any case
    Last edited by Mad Max; 9th March 2006 at 05:14.

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Question Re: QWidget on WidgetStack

    With your code, pagestack 1 appear empty, in the same way using raiseWidget(MultipleView); it works only with raiseWidget(myWidget2) but it isn't what I want...

    I created a stack widget from designer; in page called MultipleView I must put on 2 widget, widget1 and 2; for this do I need layout!? Furthermore, I need call this page with
    WidgetStack->raiseWidget(MultipleView); (this was how works before I toggled widget1 and widget2 on MultipleView (I toggled it from designer and now I'd like put they from MainForm...). Is it possible? Thanks
    Last edited by mickey; 9th March 2006 at 12:08.
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget on WidgetStack

    Sorry, I've slightly not understood what you want. I've created 2 widget in designer (Form1 and Form2) and placed they to QWidgetStack. Also, I've created an joint widget (Form1 + Form2) and placed it to QWidgetStack also:
    Qt Code:
    1. int main( int argc, char ** argv )
    2. {
    3. QApplication a( argc, argv );
    4. FormMain w;
    5.  
    6. w.widgetStack1->addWidget(new Form1(&w));
    7. w.widgetStack1->addWidget(new Form2(&w));
    8.  
    9. QWidget * MultiView = new QWidget(&w);
    10. QHBoxLayout * lo = new QHBoxLayout(MultiView);
    11. lo->addWidget(new Form1(MultiView));
    12. lo->addWidget(new Form2(MultiView));
    13.  
    14. w.widgetStack1->addWidget(MultiView);
    15.  
    16. w.show();
    17. w.widgetStack1->raiseWidget(MultiView);
    18.  
    19. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    It does work ok. Is it that which necessary for you?

  9. #9
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QWidget on WidgetStack

    Maybe...I'm using widgetstack and Widget create from designer......
    I insert and show my widget on MultipleView QWidget finally but I'm far to my taget. My new situation is this:
    Qt Code:
    1. myWidget2 = new MyWidget(MultipleView, "myWidget2", MainForm::myWidget1);
    2. myWidget3 = new MyWidget(MultipleView, "myWidget3", MainForm::myWidget1);
    3. myWidget2->setGeometry(0,0, 300, 300);
    4. myWidget2->setGeometry(300,0, 300, 300);
    5. WidgetStack->raiseWidget(MultipleView);
    To copy to clipboard, switch view to plain text mode 
    This above works: I'd like to set geometry Maximum space available (half for each widget....but I don't know how...)
    Furthermore, I think is better they in a QHLayout...but I don't know how.....Do you understand? thanks
    Regards

Similar Threads

  1. QtScript Binding problem with QWidget
    By zack in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 09:38
  2. Replies: 0
    Last Post: 11th November 2008, 15:36
  3. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  4. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  5. Replies: 3
    Last Post: 8th March 2007, 14:54

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.