From e37bc42143160ebe83765456ba306aaa77c12311 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 23 Nov 2015 14:52:20 +0100 Subject: [PATCH] [TASK] Finally add cool scrollbars to the tabs. --- imageviewer-qt4.cpp | 123 ++++++++++++++++++++++++++------------------ imageviewer-qt4.h | 25 ++++++--- 2 files changed, 91 insertions(+), 57 deletions(-) diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index ddf05d4..938bc95 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -482,9 +482,17 @@ void ImageViewer::succeedingHistogrammAdaption() { void ImageViewer::generateControlPanels() { // Tab for first task - task_tab_widget1 = new QWidget(); - task_tab1 = new QVBoxLayout(); - task_tab_widget1->setLayout(task_tab1); + task_tab1_widget = new QWidget(); + task_tab1_vboxlayout = new QVBoxLayout(); + task_tab1_widget->setLayout(task_tab1_vboxlayout); + task_tab1_scrollwidget = new QWidget(); + task_tab1_scrollarea = new QScrollArea(); + task_tab1_scrollarea->setWidgetResizable(true); + task_tab1_scrollarea->setWidget(task_tab1_scrollwidget); + task_tab1_vboxlayout->addWidget(task_tab1_scrollarea); + task_tab1_scrolllayout = new QVBoxLayout(); + task_tab1_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize); + task_tab1_scrollwidget->setLayout(task_tab1_scrolllayout); monochrome = new QPushButton(); monochrome->setText("Convert to monochrome"); @@ -516,23 +524,31 @@ void ImageViewer::generateControlPanels() { line_slider->setValue(3); //QObject::connect(lineSlider, SIGNAL(valueChanged(int)), this, SLOT (drawRainbowCross())); - task_tab1->addWidget(reset_working_copy); - task_tab1->addWidget(save_to_original); - task_tab1->addWidget(monochrome); - task_tab1->addWidget(new QLabel("Let's draw something!")); - task_tab1->addWidget(draw_black_line); - task_tab1->addWidget(draw_rainbow_cross); - task_tab1->addWidget(diagonal_cross); - task_tab1->addWidget(line_slider); - task_tab1->addWidget(new QLabel("Sets the width of the cross.")); + task_tab1_scrolllayout->addWidget(reset_working_copy); + task_tab1_scrolllayout->addWidget(save_to_original); + task_tab1_scrolllayout->addWidget(monochrome); + task_tab1_scrolllayout->addWidget(new QLabel("Let's draw something!")); + task_tab1_scrolllayout->addWidget(draw_black_line); + task_tab1_scrolllayout->addWidget(draw_rainbow_cross); + task_tab1_scrolllayout->addWidget(diagonal_cross); + task_tab1_scrolllayout->addWidget(line_slider); + task_tab1_scrolllayout->addWidget(new QLabel("Sets the width of the cross.")); - tabWidget->addTab(task_tab_widget1, "Task #1"); + tabWidget->addTab(task_tab1_widget, "Task #1"); - //Tab for second task - task_tab_widget2 = new QWidget(); - task_tab2 = new QVBoxLayout(); - task_tab_widget2->setLayout(task_tab2); + // Tab for second task + task_tab2_widget = new QWidget(); + task_tab2_vboxlayout = new QVBoxLayout(); + task_tab2_widget->setLayout(task_tab2_vboxlayout); + task_tab2_scrollwidget = new QWidget(); + task_tab2_scrollarea = new QScrollArea(); + task_tab2_scrollarea->setWidgetResizable(true); + task_tab2_scrollarea->setWidget(task_tab2_scrollwidget); + task_tab2_vboxlayout->addWidget(task_tab2_scrollarea); + task_tab2_scrolllayout = new QVBoxLayout(); + task_tab2_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize); + task_tab2_scrollwidget->setLayout(task_tab2_scrolllayout); reference_histogramm_label = new QLabel(); reference_histogramm_label->setBackgroundRole(QPalette::Base); @@ -580,29 +596,38 @@ void ImageViewer::generateControlPanels() { contrast_percentile_slider->setValue(10); QObject::connect(contrast_percentile_slider, SIGNAL(valueChanged(int)), this, SLOT(robustAutomaticContrastAdaption(int))); - task_tab2->addWidget(new QLabel("Reference image")); - task_tab2->addWidget(reference_stats); - task_tab2->addWidget(reference_histogramm_label); - task_tab2->addWidget(new QLabel("Original image")); - task_tab2->addWidget(original_stats); - task_tab2->addWidget(original_histogramm_label); - task_tab2->addWidget(new QLabel("Working copy")); - task_tab2->addWidget(stats); - task_tab2->addWidget(histogramm_label); - task_tab2->addWidget(analyze_image); - task_tab2->addWidget(new QLabel("Brightness")); - task_tab2->addWidget(brightness_slider); - task_tab2->addWidget(new QLabel("Contrast")); - task_tab2->addWidget(contrast_slider); - task_tab2->addWidget(new QLabel("Automatic Contrast Percentile")); - task_tab2->addWidget(contrast_percentile_slider); + task_tab2_scrolllayout->addWidget(new QLabel("Reference image")); + task_tab2_scrolllayout->addWidget(reference_stats); + task_tab2_scrolllayout->addWidget(reference_histogramm_label); + task_tab2_scrolllayout->addWidget(new QLabel("Original image")); + task_tab2_scrolllayout->addWidget(original_stats); + task_tab2_scrolllayout->addWidget(original_histogramm_label); + task_tab2_scrolllayout->addWidget(new QLabel("Working copy")); + task_tab2_scrolllayout->addWidget(stats); + task_tab2_scrolllayout->addWidget(histogramm_label); + task_tab2_scrolllayout->addWidget(analyze_image); + task_tab2_scrolllayout->addWidget(new QLabel("Brightness")); + task_tab2_scrolllayout->addWidget(brightness_slider); + task_tab2_scrolllayout->addWidget(new QLabel("Contrast")); + task_tab2_scrolllayout->addWidget(contrast_slider); + task_tab2_scrolllayout->addWidget(new QLabel("Automatic Contrast Percentile")); + task_tab2_scrolllayout->addWidget(contrast_percentile_slider); - tabWidget->addTab(task_tab_widget2, "Task #2"); + tabWidget->addTab(task_tab2_widget, "Task #2"); - //Tab for third task - task_tab_widget3 = new QWidget(); - task_tab3 = new QVBoxLayout(); - task_tab_widget3->setLayout(task_tab3); + + // Tab for third task + task_tab3_widget = new QWidget(); + task_tab3_vboxlayout = new QVBoxLayout(); + task_tab3_widget->setLayout(task_tab3_vboxlayout); + task_tab3_scrollwidget = new QWidget(); + task_tab3_scrollarea = new QScrollArea(); + task_tab3_scrollarea->setWidgetResizable(true); + task_tab3_scrollarea->setWidget(task_tab3_scrollwidget); + task_tab3_vboxlayout->addWidget(task_tab3_scrollarea); + task_tab3_scrolllayout = new QVBoxLayout(); + task_tab3_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize); + task_tab3_scrollwidget->setLayout(task_tab3_scrolllayout); reference_histogramm_cumulative_label = new QLabel(); reference_histogramm_cumulative_label->setBackgroundRole(QPalette::Base); @@ -634,18 +659,18 @@ void ImageViewer::generateControlPanels() { succeeding_histogramm_adaption = new QPushButton("Do succeeding histogramm adaption"); QObject::connect(succeeding_histogramm_adaption, SIGNAL(clicked()), this, SLOT(succeedingHistogrammAdaption())); - task_tab3->addWidget(new QLabel("Reference image")); - task_tab3->addWidget(reference_histogramm_cumulative_label); - task_tab3->addWidget(new QLabel("Original image")); - task_tab3->addWidget(original_histogramm_cumulative_label); - task_tab3->addWidget(new QLabel("Working copy")); - task_tab3->addWidget(histogramm_cumulative_label); - task_tab3->addWidget(linear_histogramm_adaption); - task_tab3->addWidget(partial_adaption_pieces_slider); - task_tab3->addWidget(partial_linear_histogramm_adaption); - task_tab3->addWidget(succeeding_histogramm_adaption); + task_tab3_scrolllayout->addWidget(new QLabel("Reference image")); + task_tab3_scrolllayout->addWidget(reference_histogramm_cumulative_label); + task_tab3_scrolllayout->addWidget(new QLabel("Original image")); + task_tab3_scrolllayout->addWidget(original_histogramm_cumulative_label); + task_tab3_scrolllayout->addWidget(new QLabel("Working copy")); + task_tab3_scrolllayout->addWidget(histogramm_cumulative_label); + task_tab3_scrolllayout->addWidget(linear_histogramm_adaption); + task_tab3_scrolllayout->addWidget(partial_adaption_pieces_slider); + task_tab3_scrolllayout->addWidget(partial_linear_histogramm_adaption); + task_tab3_scrolllayout->addWidget(succeeding_histogramm_adaption); - tabWidget->addTab(task_tab_widget3, "Task #3"); + tabWidget->addTab(task_tab3_widget, "Task #3"); //Show it tabWidget->show(); diff --git a/imageviewer-qt4.h b/imageviewer-qt4.h index c97700d..ac6d490 100644 --- a/imageviewer-qt4.h +++ b/imageviewer-qt4.h @@ -72,8 +72,11 @@ class ImageViewer : public QMainWindow { private: // First task tab - QWidget* task_tab_widget1; - QVBoxLayout* task_tab1; + QWidget* task_tab1_widget; + QVBoxLayout* task_tab1_vboxlayout; + QWidget* task_tab1_scrollwidget; + QScrollArea* task_tab1_scrollarea; + QVBoxLayout* task_tab1_scrolllayout; QPushButton* draw_black_line; QPushButton* draw_rainbow_cross; @@ -85,9 +88,12 @@ class ImageViewer : public QMainWindow { QSlider* line_slider; // Second task tab - QWidget* task_tab_widget2; - QVBoxLayout* task_tab2; - + QWidget* task_tab2_widget; + QVBoxLayout* task_tab2_vboxlayout; + QWidget* task_tab2_scrollwidget; + QScrollArea* task_tab2_scrollarea; + QVBoxLayout* task_tab2_scrolllayout; + QLabel* reference_stats; QLabel* original_stats; QLabel* stats; @@ -102,9 +108,12 @@ class ImageViewer : public QMainWindow { QSlider* contrast_percentile_slider; // Third task tab - QWidget* task_tab_widget3; - QVBoxLayout* task_tab3; - + QWidget* task_tab3_widget; + QVBoxLayout* task_tab3_vboxlayout; + QWidget* task_tab3_scrollwidget; + QScrollArea* task_tab3_scrollarea; + QVBoxLayout* task_tab3_scrolllayout; + QLabel* reference_histogramm_cumulative_label; QLabel* original_histogramm_cumulative_label; QLabel* histogramm_cumulative_label;