Changeset - b30de3bb2421
[Not reviewed]
default
0 2 2
Hasan Yavuz ÖZDERYA - 10 years ago 2015-07-30 14:39:34
hy@ozderya.net
added hide button to tab widget
4 files changed with 64 insertions and 1 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -61,6 +61,7 @@ add_executable(${PROGRAM_NAME} WIN32
 
  customcheckablebutton.cpp
 
  plot.cpp
 
  zoomer.cpp
 
  hidabletabwidget.cpp
 
  ${UI_FILES}
 
  misc/windows_icon.rc
 
  )
hidabletabwidget.cpp
Show inline comments
 
new file 100644
 
#include "hidabletabwidget.h"
 
#include <QTabBar>
 
#include <QToolButton>
 

	
 
HidableTabWidget::HidableTabWidget(QWidget *parent) :
 
    QTabWidget(parent),
 
    hideAction("▾", this)
 
{
 
    hideAction.setCheckable(true);
 
    hideAction.setToolTip("Hide Panels");
 
    QToolButton* hideButton = new QToolButton();
 
    hideButton->setDefaultAction(&hideAction);
 
    hideButton->setAutoRaise(true);
 
    this->setCornerWidget(hideButton);
 

	
 
    connect(&hideAction, SIGNAL(toggled(bool)), this, SLOT(onHideAction(bool)));
 
    connect(this, SIGNAL(tabBarClicked(int)), this, SLOT(onTabBarClicked()));
 
}
 

	
 
void HidableTabWidget::onHideAction(bool checked)
 
{
 
    if (checked)
 
    {
 
        this->setMaximumHeight(this->tabBar()->height());
 
        this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
 
    }
 
    else
 
    {
 
        this->setMaximumHeight(100000); // just a very big number
 
        this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
    }
 
}
 

	
 
void HidableTabWidget::onTabBarClicked()
 
{
 
    hideAction.setChecked(false);
 
}
hidabletabwidget.h
Show inline comments
 
new file 100644
 
#ifndef HIDABLETABWIDGET_H
 
#define HIDABLETABWIDGET_H
 

	
 
#include <QTabWidget>
 
#include <QAction>
 

	
 
class HidableTabWidget : public QTabWidget
 
{
 
    Q_OBJECT
 
public:
 
    explicit HidableTabWidget(QWidget *parent = 0);
 
    QAction hideAction;
 

	
 
private slots:
 
    void onHideAction(bool checked);
 
    void onTabBarClicked();
 
};
 

	
 
#endif // HIDABLETABWIDGET_H
mainwindow.ui
Show inline comments
 
@@ -26,7 +26,7 @@
 
     </widget>
 
    </item>
 
    <item>
 
     <widget class="QTabWidget" name="tabWidget">
 
     <widget class="HidableTabWidget" name="tabWidget">
 
      <property name="sizePolicy">
 
       <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
 
        <horstretch>0</horstretch>
 
@@ -603,6 +603,12 @@
 
   <header>plot.h</header>
 
   <container>1</container>
 
  </customwidget>
 
  <customwidget>
 
   <class>HidableTabWidget</class>
 
   <extends>QTabWidget</extends>
 
   <header>hidabletabwidget.h</header>
 
   <container>1</container>
 
  </customwidget>
 
 </customwidgets>
 
 <resources/>
 
 <connections/>
0 comments (0 inline, 0 general)