@@ -26,7 +26,6 @@ limitations under the License.
2626#include < QCheckBox>
2727#include < QToolButton>
2828#include < QPropertyAnimation>
29- #include < QResizeEvent>
3029#include < QFrame>
3130
3231// ExpandableGroupBox implementation
@@ -715,46 +714,33 @@ void TTDMemoryWidget::setupUI()
715714
716715 QVBoxLayout* mainLayout = new QVBoxLayout (this );
717716
718- // Create a horizontal layout to hold the tab widget and + button
719- QWidget* tabContainer = new QWidget ();
720- m_tabLayout = new QHBoxLayout (tabContainer);
721- m_tabLayout->setContentsMargins (0 , 0 , 0 , 0 );
722- m_tabLayout->setSpacing (0 );
723-
724717 // Tab widget setup
725- m_tabWidget = new QTabWidget ();
718+ m_tabWidget = new QTabWidget (this );
726719 m_tabWidget->setTabsClosable (true );
727720 connect (m_tabWidget, &QTabWidget::tabCloseRequested, this , &TTDMemoryWidget::closeTab);
728721
729- // Create "+" button
730- m_newTabButton = new QPushButton (" +" );
731- m_newTabButton->setMaximumSize (25 , 25 );
732- m_newTabButton->setMinimumSize (25 , 25 );
733- m_newTabButton->setToolTip (" Create new query tab" );
734- m_newTabButton->setStyleSheet (" QPushButton { border: 1px solid #555; border-radius: 3px; margin-top: 2px; }" );
735- connect (m_newTabButton, &QPushButton::clicked, this , &TTDMemoryWidget::createNewTab);
722+ // Create "+" button as corner widget
723+ m_newTabButton = new QToolButton (m_tabWidget);
724+ m_newTabButton->setText (" +" );
725+ m_newTabButton->setAutoRaise (true );
726+ m_newTabButton->setToolTip (" New tab" );
727+ connect (m_newTabButton, &QToolButton::clicked, this , &TTDMemoryWidget::createNewTab);
736728
737- // Add tab widget and button to horizontal layout
738- m_tabLayout->addWidget (m_tabWidget);
739- m_tabLayout->addWidget (m_newTabButton, 0 , Qt::AlignTop);
729+ // Set the button as corner widget
730+ m_tabWidget->setCornerWidget (m_newTabButton, Qt::TopRightCorner);
740731
741- mainLayout->addWidget (tabContainer );
732+ mainLayout->addWidget (m_tabWidget );
742733 setLayout (mainLayout);
743734
744735 // Create initial tab
745736 createNewTab ();
746-
747- // Update button position when tabs change
748- connect (m_tabWidget, &QTabWidget::currentChanged, this , &TTDMemoryWidget::updateNewTabButtonPosition);
749- connect (m_tabWidget, &QTabWidget::tabBarClicked, this , &TTDMemoryWidget::updateNewTabButtonPosition);
750737}
751738
752739void TTDMemoryWidget::createNewTab ()
753740{
754741 TTDMemoryQueryWidget* queryWidget = new TTDMemoryQueryWidget (this , m_data);
755742 int tabIndex = m_tabWidget->addTab (queryWidget, QString (" Query %1" ).arg (m_tabWidget->count () + 1 ));
756743 m_tabWidget->setCurrentIndex (tabIndex);
757- updateNewTabButtonPosition ();
758744}
759745
760746void TTDMemoryWidget::closeTab (int index)
@@ -764,21 +750,9 @@ void TTDMemoryWidget::closeTab(int index)
764750 QWidget* widget = m_tabWidget->widget (index);
765751 m_tabWidget->removeTab (index);
766752 widget->deleteLater ();
767- updateNewTabButtonPosition ();
768753 }
769754}
770755
771- void TTDMemoryWidget::updateNewTabButtonPosition ()
772- {
773- // This will be called to adjust the button position if needed
774- // For now, the horizontal layout should handle this automatically
775- }
776-
777- void TTDMemoryWidget::resizeEvent (QResizeEvent* event)
778- {
779- QWidget::resizeEvent (event);
780- updateNewTabButtonPosition ();
781- }
782756
783757
784758// TTDMemorySidebarWidget implementation
0 commit comments