Commit 0c479ac8 authored by captainwong's avatar captainwong

jlibqt/BaseScrollView

parent 2869e857
#include "BaseScrollView.h"
#include <qscrollbar.h>
#include "../QtUtils.h"
#include "../QtStylesheet.h"
using namespace jlib::qt;
BaseScrollView::BaseScrollView(QWidget *parent)
: QScrollArea(parent)
{
setFrameShape(QFrame::NoFrame);
verticalScrollBar()->setStyleSheet(def_style_sheets::vertical_scroll_bar);
//fill_bg_with_color(this, def_colors::window_bk);
root_ = new QWidget(this);
setWidget(root_);
refresh();
}
BaseScrollView::~BaseScrollView()
{
}
void BaseScrollView::resizeEvent(QResizeEvent *)
{
root_->resize(width() - 8, qMax(height(), root_->height()));
}
void BaseScrollView::refresh()
{
root_->move(0, 0);
root_->resize(width() - 8, qMax(height(), root_->height()));
//fill_bg_with_color(root_, def_colors::control_bk);
}
#pragma once
#include <QScrollArea>
class BaseScrollView : public QScrollArea
{
Q_OBJECT
public:
BaseScrollView(QWidget *parent = nullptr);
~BaseScrollView();
auto root() const { return root_; }
virtual void refresh();
protected:
virtual void resizeEvent(QResizeEvent*) override;
private:
QWidget* root_ = {};
};
......@@ -93,6 +93,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="qt.cpp" />
<ClCompile Include="View\BaseScrollView.cpp" />
<ClCompile Include="View\BgColorBtn.cpp" />
<ClCompile Include="View\IconBtn.cpp" />
<ClCompile Include="View\PageTitle.cpp" />
......@@ -100,6 +101,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<QtMoc Include="View\BaseScrollView.h" />
<QtMoc Include="View\RndButton.h" />
<QtMoc Include="View\PageTitle.h" />
<QtMoc Include="View\IconBtn.h" />
......
......@@ -45,6 +45,9 @@
<ClCompile Include="View\BgColorBtn.cpp">
<Filter>View</Filter>
</ClCompile>
<ClCompile Include="View\BaseScrollView.cpp">
<Filter>View</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="qt.h">
......@@ -96,5 +99,8 @@
<QtMoc Include="View\RndButton.h">
<Filter>View</Filter>
</QtMoc>
<QtMoc Include="View\BaseScrollView.h">
<Filter>View</Filter>
</QtMoc>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment