add a simple frame component used in examples
This commit is contained in:
parent
e1a44b78db
commit
4621d08cdc
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef ABOUT_H
|
||||||
|
#define ABOUT_H
|
||||||
|
|
||||||
|
#endif // ABOUT_H
|
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef EXAMPLELIST_H
|
||||||
|
#define EXAMPLELIST_H
|
||||||
|
|
||||||
|
#endif // EXAMPLELIST_H
|
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef EXAMPLEVIEW_H
|
||||||
|
#define EXAMPLEVIEW_H
|
||||||
|
|
||||||
|
#endif // EXAMPLEVIEW_H
|
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef FLATBUTTONEXAMPLES_H
|
||||||
|
#define FLATBUTTONEXAMPLES_H
|
||||||
|
|
||||||
|
#endif // FLATBUTTONEXAMPLES_H
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include "frame.h"
|
||||||
|
|
||||||
|
Frame::Frame(QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
_edit(new QTextEdit),
|
||||||
|
_layout(new QHBoxLayout)
|
||||||
|
{
|
||||||
|
setLayout(_layout);
|
||||||
|
|
||||||
|
_layout->addWidget(new QLabel("placeholder"));
|
||||||
|
|
||||||
|
QFont font("monospace");
|
||||||
|
font.setPixelSize(12);
|
||||||
|
|
||||||
|
_edit->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
_edit->setFont(font);
|
||||||
|
_layout->addWidget(_edit);
|
||||||
|
|
||||||
|
_layout->setStretch(0, 1);
|
||||||
|
_layout->setStretch(1, 1);
|
||||||
|
|
||||||
|
setMinimumHeight(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
Frame::~Frame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Frame::setCodeSnippet(const QString &snippet)
|
||||||
|
{
|
||||||
|
_edit->setText(snippet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Frame::setWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
QWidget *old = _layout->itemAt(0)->widget();
|
||||||
|
_layout->replaceWidget(old, widget);
|
||||||
|
old->deleteLater();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef FRAME_H
|
||||||
|
#define FRAME_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QTextEdit;
|
||||||
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
class Frame : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Frame(QWidget *parent = 0);
|
||||||
|
~Frame();
|
||||||
|
|
||||||
|
void setCodeSnippet(const QString &snippet);
|
||||||
|
void setWidget(QWidget *widget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTextEdit *const _edit;
|
||||||
|
QHBoxLayout *const _layout;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FRAME_H
|
Loading…
Reference in New Issue