Results 1 to 3 of 3

Thread: Combine Widgets in a new class

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Question Combine Widgets in a new class

    Hi,
    I'm trying to build a new class that provides a combination of two QWidgets: one title bar and one collapsible (->hideable) content widget ("panel"). As I will need several very different panel layouts I have an "abstract" (not really virtual) class that is inherited - the heir doesn't change anything as of now, though.

    The code compiles, but I don't see the desired appearance - As for now I have put a QPushButton in titleBarWidget and panelWidget, but both seem to be displayed on top of each other.

    I am pretty sure it is a very simple beginner's problem. I am very new to C++ and Qt so I might be lacking a very basic concept here. My code:

    Qt Code:
    1. AbstractCont::AbstractCont(QWidget *parent) :
    2. QWidget(parent)
    3. {
    4.  
    5. this->setVisible(true);
    6. this->resize(400,400);
    7. this->show();
    8.  
    9. this->titleBarWidget = new QWidget(this);
    10. this->titleBarWidget->setVisible(true);
    11. this->titleBarWidget->resize(100,100);
    12. this->titleBarWidget->show();
    13. this->titleBarWidget->setBackgroundRole(QPalette::Window);
    14.  
    15. QPushButton *pushButt1 = new QPushButton("Title", this->titleBarWidget);
    16. pushButt1->resize(50,50);
    17. pushButt1->show();
    18.  
    19. this->panelWidget=new QWidget(this);
    20. this->panelWidget->setVisible(true);
    21. this->panelWidget->resize(100,100);
    22. this->panelWidget->show();
    23.  
    24. QPushButton *pushButt2 = new QPushButton("Panel", this->panelWidget);
    25. pushButt2->resize(50,50);
    26. pushButt2->show();
    27. }
    To copy to clipboard, switch view to plain text mode 

    This is used by:

    Qt Code:
    1. Cont_Anwesenheit::Cont_Anwesenheit(...):AbstractCont(parent)
    2. {
    3. };
    To copy to clipboard, switch view to plain text mode 

    Which is again called by:
    Qt Code:
    1. AbstractCont *cont = new Cont_Anwesenheit("Die ID","Kursname", this->model, this->scene, dock);
    To copy to clipboard, switch view to plain text mode 

    The variable cont has to be able to hold different heritages of AbstractCont, thus the type.

    What I see is attached: just the Button with "Panel". What I like to achieve (just an example, not exactly) is also attached

    Any help would be gratefully appreciated!

    Best Regards,
    Sebastian
    Attached Images Attached Images

  2. The following user says thank you to sedi for this useful post:

    Dr.Microso (28th March 2013)

  3. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Combine Widgets in a new class

    Read about Layout Management

  4. The following user says thank you to ChrisW67 for this useful post:

    sedi (30th January 2012)

  5. #3
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Combine Widgets in a new class

    Oops. Seems like I haven't seen the wood for the trees. Learning is an embarrassing thing to to :-) Thank you!

Similar Threads

  1. Class for mapping input widgets
    By Hostel in forum Newbie
    Replies: 2
    Last Post: 13th September 2011, 09:21
  2. combine Symbian C++ and Qt
    By Manjula in forum Newbie
    Replies: 0
    Last Post: 9th March 2011, 14:53
  3. How to use widgets of other ui within a class???
    By sinha.ashish in forum Qt Programming
    Replies: 1
    Last Post: 10th April 2008, 15:30
  4. Replies: 11
    Last Post: 7th July 2006, 13:09

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
  •  
Qt is a trademark of The Qt Company.