I managed to figure this out, it seemed pretty simple.
customtab.hpp
#ifndef CUSTOMTAB_HPP
#define CUSTOMTAB_HPP
#include <QTabWidget>
#include <QLabel>
{
public:
~CustomTab();
virtual void tabInserted( int aIndex );
virtual void tabRemoved( int aIndex );
protected:
void SetLabelPosition();
private:
};
#endif // CUSTOMTAB_HPP
#ifndef CUSTOMTAB_HPP
#define CUSTOMTAB_HPP
#include <QTabWidget>
#include <QLabel>
class CustomTab : public QTabWidget
{
public:
CustomTab( QWidget* aParent = 0 );
~CustomTab();
virtual void tabInserted( int aIndex );
virtual void tabRemoved( int aIndex );
virtual void resizeEvent(QResizeEvent* aEvent );
protected:
void SetLabelPosition();
private:
QLabel* iLabel;
};
#endif // CUSTOMTAB_HPP
To copy to clipboard, switch view to plain text mode
customtab.cpp
#include "customtab.hpp"
#include <QTabBar>
CustomTab
::CustomTab( QWidget* aParent
){
iLabel->setText( "Double click on a file segment to open it." );
if (count())
{
iLabel->setVisible(false);
}
iLabel->setWordWrap(true);
SetLabelPosition();
}
CustomTab::~CustomTab()
{
delete iLabel;
}
void CustomTab::tabInserted( int aIndex )
{
if ( count() )
{
iLabel->setVisible(false);
}
}
void CustomTab::tabRemoved( int aIndex )
{
if ( !count() )
{
iLabel->setVisible(true);
}
}
{
SetLabelPosition();
}
void CustomTab::SetLabelPosition()
{
int xpos = width() /2 - iLabel->width() / 2;
int ypos = height() /2 - iLabel->height() /2;
iLabel->move( xpos, ypos );
}
// End of file
#include "customtab.hpp"
#include <QTabBar>
CustomTab::CustomTab( QWidget* aParent )
: QTabWidget( aParent ), iLabel( NULL )
{
iLabel = new QLabel( this );
iLabel->setText( "Double click on a file segment to open it." );
if (count())
{
iLabel->setVisible(false);
}
iLabel->setWordWrap(true);
SetLabelPosition();
}
CustomTab::~CustomTab()
{
delete iLabel;
}
void CustomTab::tabInserted( int aIndex )
{
if ( count() )
{
iLabel->setVisible(false);
}
}
void CustomTab::tabRemoved( int aIndex )
{
if ( !count() )
{
iLabel->setVisible(true);
}
}
void CustomTab::resizeEvent( QResizeEvent* aEvent )
{
QTabWidget::resizeEvent( aEvent );
SetLabelPosition();
}
void CustomTab::SetLabelPosition()
{
int xpos = width() /2 - iLabel->width() / 2;
int ypos = height() /2 - iLabel->height() /2;
iLabel->move( xpos, ypos );
}
// End of file
To copy to clipboard, switch view to plain text mode
Bookmarks