My QtabBar is not displaying although it is compiling fine and showing the controls.
Qt Code:
QTab *tab1 = new QTab("General"); qtb.addTab(tab1); QTab *tab2 = new QTab("About"); qtb.addTab(tab2);To copy to clipboard, switch view to plain text mode
My QtabBar is not displaying although it is compiling fine and showing the controls.
Qt Code:
QTab *tab1 = new QTab("General"); qtb.addTab(tab1); QTab *tab2 = new QTab("About"); qtb.addTab(tab2);To copy to clipboard, switch view to plain text mode
Last edited by Dune; 7th February 2006 at 15:51. Reason: subscribe
What is the type of that qtb variable? Do you use QTabWidget?
qtb is QTabBar
I am using QDialog because I thought QTabWidget was for putting widgets in the tabs. Ok controls are called widgets in qt.
My example
Qt Code:
d_tab_bar->addTab( d_view_tab = new QTab() ); d_tab_bar->addTab( d_console_tab = new QTab() );To copy to clipboard, switch view to plain text mode
best regards
piotr
Thanks and I should inherit from QTabWidget?Originally Posted by piotrpsz
No. In my code is all what you needOriginally Posted by Dune
![]()
Does your code require QWidgetStack/QStackedWidget to display tabs?Originally Posted by piotrpsz
Full example (with QWidgetStack):Originally Posted by jacek
Qt Code:
{ if( layout ) { layout->addWidget( d_widget_stack = new QWidgetStack( parent )); d_widget_stack->addWidget( d_workspace = new Workspace( parent )); d_widget_stack->addWidget( new Console( parent )); d_tab_bar->addTab( d_view_tab = new QTab() ); d_tab_bar->addTab( d_console_tab = new QTab() ); connect( d_tab_bar, SIGNAL( selected( int ) ), this, SLOT( set_current_tab( int ))); } } ... void MainWindow::set_current_tab( int ) { d_widget_stack->raiseWidget( idx ); d_tab_bar->setCurrentTab( idx ); }To copy to clipboard, switch view to plain text mode
piotr
I see, so in fact you had to implement your own QTabWidget.Originally Posted by piotrpsz
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
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:
{ //widget1 = new QWidget(this); //widget2 = new QWidget(this); tabbar->addTab(viewtab = new QTab("aaaaaaaaaaaaa")); tabbar->addTab(consoletab = new QTab("dddddddddddd")); widgetstack = new QWidgetStack(this); connect(tabbar, SIGNAL(selected(1)), this, SLOT(setTab(1))); connect(tabbar, SIGNAL(selected(2)), this, SLOT(setTab(2))); //connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( )); } void TabDialog::setTab(int id) { widgetstack->raiseWidget(id); tabbar->setCurrentTab(id); resizeEvent(0); } // leave this, it's for resizing the frame and then you need sizehints for that { if(e) tabbar->setGeometry(200,0,200,30); label1->setGeometry(100,50,20,20); label2->setGeometry(100,100,20,20); }To copy to clipboard, switch view to plain text mode
You can't specify parameter names or values in SLOT and SIGNAL macros.Originally Posted by Dune
Try:Qt Code:
connect( tabbar, SIGNAL( selected( int ) ), this, SLOT( setTab( int ) ) );To copy to clipboard, switch view to plain text mode
I think the problem here was you were creating that QTabBar widget on stack and not on heap (based on the way you reference it) and it was being deleted upon return from the function.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.
Qt Code:
{ //widget1 = new QWidget(this); //widget2 = new QWidget(this); tabbar->addTab(viewtab = new QTab("aaaaaaaaaaaaa")); tabbar->addTab(consoletab = new QTab("bbbbbbbbbb")); widgetstack = new QWidgetStack(this); connect(tabbar, SIGNAL(selected(int)), this, SLOT(setTab(int))); //connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( )); } void TabDialog::setTab(int idx) { if(idx == 1) { widgetstack->raiseWidget(1); } if(idx == 2) { widgetstack->raiseWidget(2); } resizeEvent(0); } // leave this, it's for resizing the frame and then you need sizehints for that { if(e) tabbar->setGeometry(200,0,200,30); label1->setGeometry(100,50,20,20); label2->setGeometry(100,100,20,20); }To copy to clipboard, switch view to plain text mode
here is my class code:Originally Posted by wysota
Qt Code:To copy to clipboard, switch view to plain text mode
Ok I am new to pointers. I can only use this '->' with pointers.
Did you set a layout for your dialog? Maybe it will be easier for you to use Qt Designer?Originally Posted by Dune
Woudn't it be easier to write:Qt Code:
if(idx == 1) { widgetstack->raiseWidget(1); } if(idx == 2) { widgetstack->raiseWidget(2); }To copy to clipboard, switch view to plain text mode?Qt Code:
widgetstack->raiseWidget( idx );To copy to clipboard, switch view to plain text mode
Thanks and no I dont use that stuff
I want using a layout but I guess I can.
Bookmarks