Results 1 to 18 of 18

Thread: QTAbBar not displaying

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTAbBar not displaying

    Working for me so far. I had to set it up in inheritance mode for me and of course change some formatting to my own. I will see if I can just inherit from the WidgetStack now instaed of using QFrame.

    EDIT:
    Eh, I need the QFrame as a parent.
    Last edited by Dune; 8th February 2006 at 16:18. Reason: No parent

  2. #2
    Join Date
    Feb 2006
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTAbBar not displaying

    I can't get my labels to change stack position. I would assume when one is raised that it would be on top of the other plus the labels are not changing geometry.

    Qt Code:
    1. TabDialog::TabDialog(QWidget *parent, const char *name, const QString &_filename)
    2. : QFrame(parent, name), filename(_filename), fileinfo(filename)
    3. {
    4. //widget1 = new QWidget(this);
    5. //widget2 = new QWidget(this);
    6. tabbar = new QTabBar(this);
    7.  
    8. tabbar->setShape(QTabBar::RoundedAbove);
    9. tabbar->addTab(viewtab = new QTab("aaaaaaaaaaaaa"));
    10. tabbar->addTab(consoletab = new QTab("dddddddddddd"));
    11.  
    12. widgetstack = new QWidgetStack(this);
    13.  
    14. widgetstack->addWidget(label1= new QLabel("ccccccccccc", this), 1);
    15. widgetstack->addWidget(label2 = new QLabel("ggggggggggg", this), 2);
    16. label1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    17. label2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    18.  
    19. connect(tabbar, SIGNAL(selected(1)), this, SLOT(setTab(1)));
    20. connect(tabbar, SIGNAL(selected(2)), this, SLOT(setTab(2)));
    21. //connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( ));
    22. }
    23.  
    24. void TabDialog::setTab(int id)
    25. {
    26. widgetstack->raiseWidget(id);
    27. tabbar->setCurrentTab(id);
    28. resizeEvent(0);
    29. }
    30. // leave this, it's for resizing the frame and then you need sizehints for that
    31. void TabDialog::resizeEvent(QResizeEvent *e)
    32. {
    33. if(e)
    34. QFrame::resizeEvent(e);
    35.  
    36. tabbar->setGeometry(200,0,200,30);
    37. label1->setGeometry(100,50,20,20);
    38. label2->setGeometry(100,100,20,20);
    39. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: QTAbBar not displaying

    Quote Originally Posted by Dune
    connect(tabbar, SIGNAL(selected(1)), this, SLOT(setTab(1)));
    connect(tabbar, SIGNAL(selected(2)), this, SLOT(setTab(2)));
    You can't specify parameter names or values in SLOT and SIGNAL macros.

    Try:
    Qt Code:
    1. connect( tabbar, SIGNAL( selected( int ) ), this, SLOT( setTab( int ) ) );
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTAbBar not displaying

    Thanks, I redid the code. Seems to be working as the 'aaaa' label disappears when I select a tab but the bbbbb label is hidden and my labels are at 0,0 still.

    Qt Code:
    1. TabDialog::TabDialog(QWidget *parent, const char *name, const QString &_filename)
    2. : QFrame(parent, name), filename(_filename), fileinfo(filename)
    3. {
    4. //widget1 = new QWidget(this);
    5. //widget2 = new QWidget(this);
    6. tabbar = new QTabBar(this);
    7.  
    8. tabbar->setShape(QTabBar::RoundedAbove);
    9. tabbar->addTab(viewtab = new QTab("aaaaaaaaaaaaa"));
    10. tabbar->addTab(consoletab = new QTab("bbbbbbbbbb"));
    11.  
    12. widgetstack = new QWidgetStack(this);
    13.  
    14. widgetstack->addWidget(label1= new QLabel("11111111111", this), 1);
    15. widgetstack->addWidget(label2 = new QLabel("222222222222", this), 2);
    16. label1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    17. label2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    18.  
    19. connect(tabbar, SIGNAL(selected(int)), this, SLOT(setTab(int)));
    20. //connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( ));
    21. }
    22.  
    23. void TabDialog::setTab(int idx)
    24. {
    25. if(idx == 1) {
    26. widgetstack->raiseWidget(1);
    27. }
    28. if(idx == 2) {
    29. widgetstack->raiseWidget(2);
    30. }
    31. resizeEvent(0);
    32. }
    33.  
    34. // leave this, it's for resizing the frame and then you need sizehints for that
    35. void TabDialog::resizeEvent(QResizeEvent *e)
    36. {
    37. if(e)
    38. QFrame::resizeEvent(e);
    39. tabbar->setGeometry(200,0,200,30);
    40. label1->setGeometry(100,50,20,20);
    41. label2->setGeometry(100,100,20,20);
    42. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: QTAbBar not displaying

    Quote Originally Posted by Dune
    Thanks, I redid the code. Seems to be working as the 'aaaa' label disappears when I select a tab but the bbbbb label is hidden and my labels are at 0,0 still.
    Did you set a layout for your dialog? Maybe it will be easier for you to use Qt Designer?

    Qt Code:
    1. if(idx == 1) {
    2. widgetstack->raiseWidget(1);
    3. }
    4. if(idx == 2) {
    5. widgetstack->raiseWidget(2);
    6. }
    To copy to clipboard, switch view to plain text mode 
    Woudn't it be easier to write:
    Qt Code:
    1. widgetstack->raiseWidget( idx );
    To copy to clipboard, switch view to plain text mode 
    ?

  6. #6
    Join Date
    Feb 2006
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTAbBar not displaying

    Thanks and no I dont use that stuff

    I want using a layout but I guess I can.

Similar Threads

  1. Hiding a tab in QTabBar widget
    By erik in forum Qt Programming
    Replies: 9
    Last Post: 12th February 2017, 12:29
  2. Help on QTabBar colors
    By smacchia in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2012, 16:48
  3. Using QTabBar as QTabWidget replacement
    By invictus in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2008, 01:57
  4. Problems with CSS for QTabBar and QTabWidget
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 08:38
  5. problems about QTabBar
    By qtopiahooo in forum Qt Programming
    Replies: 4
    Last Post: 10th October 2006, 10:05

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.