View Full Version : Tab Design
FoleyX90
3rd May 2010, 16:21
I was wondering (if possible) how to make my tabs look like this attachment.
It looks like the left side is rounded and right side is triangular - what the heck?
Please, help.
Lykurg
3rd May 2010, 16:34
simple subclass QTabBar and do the painting yourself!
FoleyX90
3rd May 2010, 16:36
Thanks for that recommendation. Is there any examples or tutorials online for painting?
Lykurg
3rd May 2010, 16:41
Qt Assistant is always a good point to start: http://doc.trolltech.com/4.6/examples-painting.html.
FoleyX90
3rd May 2010, 16:52
Having trouble performing: TabNavigator->setTabBar(myTabBar);
FoleyX90
3rd May 2010, 17:04
error: 'void QTabWidget::setTabBar(QTabBar*)' is protected
You have to derive from QTabWidget and QTabBar to do what you are trying to do.
FoleyX90
3rd May 2010, 17:30
It works if, in qtabwidget.h, i move settabbar from protected to public.
Yea, but then you are breaking your license agreement. So if you extend QTabWidget, then you can call setTabBar in the constructor. Problem solved.
FoleyX90
3rd May 2010, 17:49
This is probably horribly wrong (seeing as it doesn't work) but this is what i've put:
#ifndef MYTABWIDGET_H
#define MYTABWIDGET_H
#include <QTabWidget>
#include <QTabBar>
class MyTabWidget : public QTabWidget
{
public:
MyTabWidget(QTabBar *);
};
#endif // MYTABWIDGET_H
FoleyX90
3rd May 2010, 17:49
The cpp file:
#include "mytabwidget.h"
#include <QTabWidget>
MyTabWidget::MyTabWidget(QTabBar *)
{
QTabWidget::setTabBar(QTabBar *);
}
That should work, but i would do it more along these lines
MyTabWidget::MyTabWidget(QWidget *parent)
: QTabWidget(parent)
{
setTabBar(new MyTabBar(this));
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.