Пример #1
0
void HorizontalTabWidget::setCurrentIndex(int index)
{
  int xPos = 0;

  for(unsigned i = 0; i < m_tabButtons.size(); i++)
  {  
    QPushButton * button = m_tabButtons[i];

    QString style;

    style.append("QPushButton { border: none; background-color: #808080; ");
    style.append("              border-right: 1px solid black;");
    style.append("              border-bottom: 1px solid black;");
    style.append("              padding-left: 10px;");
    style.append("              padding-right: 10px;");
    style.append("              padding-top: 5px;");
    style.append("              font: bold;");
    if( i == m_tabButtons.size() - 1 )
    {
      style.append("            border-right: none;");
    }
    style.append("}");

    button->setStyleSheet(style); 

    button->adjustSize();

    button->move(xPos,0);

    xPos = xPos + button->width();
  }

  m_tabBarLine->setFixedWidth(xPos);
  m_tabBarLine->raise();

  QPushButton * button = m_tabButtons[index];

  QString style;

  // NOTE: Yellow Orange Lighter #fdbc3b and the Darker Orange is #f47920
  style.append("QPushButton { border: none; background-color: #f47920; ");
  style.append("              border-right: 1px solid black;");
  style.append("              padding-left: 10px;");
  style.append("              padding-right: 10px;");
  style.append("              padding-top: 5px;");
  style.append("              font: bold;");
  if( index == int(m_tabButtons.size() - 1) )
  {
    style.append("            border-right: none;");
  }
  style.append("}");

  button->setStyleSheet(style); 
  button->raise();

  emit tabSelected(m_ids[index]);
}
Пример #2
0
void HorizontalTabWidget::setCurrentIndex(int index)
{
  int xPos = 0;

  for(unsigned i = 0; i < m_tabButtons.size(); i++)
  {  
    QPushButton * button = m_tabButtons[i];

    QString style;

    style.append("QPushButton { border: none; background-color: #808080; ");
    style.append("              border-right: 1px solid black;");
    style.append("              border-bottom: 1px solid black;");
    style.append("              padding-left: 10px;");
    style.append("              padding-right: 10px;");
    style.append("              padding-top: 5px;");
    style.append("              color: white;");
    if( i == m_tabButtons.size() - 1 )
    {
      style.append("            border-right: none;");
    }
    style.append("}");

    button->setStyleSheet(style); 

    button->adjustSize();

    button->move(xPos,0);

    xPos = xPos + button->width();
  }

  m_tabBarLine->setFixedWidth(xPos);
  m_tabBarLine->raise();

  QPushButton * button = m_tabButtons[index];

  QString style;

  style.append("QPushButton { border: none; background-color: #95B3DE; ");
  style.append("              border-right: 1px solid black;");
  style.append("              padding-left: 10px;");
  style.append("              padding-right: 10px;");
  style.append("              padding-top: 5px;");
  style.append("              color: white;");
  if( index == int(m_tabButtons.size() - 1) )
  {
    style.append("            border-right: none;");
  }
  style.append("}");

  button->setStyleSheet(style); 
  button->raise();

  m_pageStack->setCurrentIndex(index);
}
Пример #3
0
void MainTabView::setCurrentIndex(int index)
{
  int xPos = m_tabLabel->width() + TAB_SEPARATION;

  for(unsigned i = 0; i < m_tabButtons.size(); i++)
  {  
    QPushButton * button = m_tabButtons[i];
    QString style;

    style.append("QPushButton { border: none; background-color: #BBCDE3; ");
    style.append("              border-right: 1px solid black;");
    style.append("              border-bottom: 1px solid black;");
    style.append("              border-top: 1px solid black;");
    style.append("              border-left: 1px solid black;");
    style.append("              border-top-left-radius: 5px;");
    style.append("              border-top-right-radius: 5px;");
    style.append("              padding-left: 10px;");
    style.append("              padding-right: 10px;");
    style.append("              color: black;");
    style.append("}");

    button->setStyleSheet(style); 
    button->adjustSize();
    button->move(xPos,5);

    button->stackUnder(m_mainWidget);

    xPos += TAB_SEPARATION + button->width();
  }

  QPushButton * button = m_tabButtons[index];

  QString style;

  style.append("QPushButton { border: none; background-color: #E6E6E6; ");
  style.append("              border-right: 1px solid black;");
  style.append("              border-bottom: none;");
  style.append("              border-top: 1px solid black;");
  style.append("              border-left: 1px solid black;");
  style.append("              border-top-left-radius: 5px;");
  style.append("              border-top-right-radius: 5px;");
  style.append("              padding-left: 10px;");
  style.append("              padding-right: 10px;");
  style.append("              color: black;");
  style.append("}");

  button->setStyleSheet(style); 
  button->raise();

  m_stackedWidget->setCurrentIndex(index);

  emit tabSelected(m_ids[index]);
}