#include "parent.hpp"
int main()
{
Parent object;
return 0;
}
#ifndef PARENT_HPP
#define PARENT_HPP
#include "child.hpp"
class Parent
{
friend class Child;
private:
Child child{this};
public:
Parent() = default;
~Parent() = default;
private:
void doNothing() const;
};
#endif // PARENT_HPP
#ifndef CHILD_HPP
#define CHILD_HPP
class Parent;
class Child
{
private:
Parent *parent;
public:
Child(Parent *parent);
~Child() = default;
};
#endif // CHILD_HPP
#include "parent.hpp"
#include <iostream>
void Parent::doNothing() const
{
std::clog << "Do nothing!\n" << std::endl;
}
#include "child.hpp"
#include "parent.hpp"
Child::Child(Parent *_parent) : parent(_parent)
{
parent->doNothing();
}
QVideoFrame
есть метод isMapped()
, который показывает, размещен ли кадр в ОЗУ (или в виртуальной памяти, т.е. находится ли он в адресуемой памяти и можно ли получить к нему доступ). Оказалось что нет.QVideoProbe::videoFrameProbed()
передаёт ссылку на константу QVideoFrame
, а функция QVideoFrame::map()
не константна, то нужно скопировать кадр:void MainWindow::proccessFrame(const QVideoFrame &frame)
{
QVideoFrame replica = frame;
replica.map(QAbstractVideoBuffer::ReadOnly);
std::clog << std::boolalpha << frame.isMapped() << "\n";
std::clog << std::boolalpha << replica.isMapped() << "\n";
QImage image{ replica.bits(), replica.width(),
replica.height(), replica.bytesPerLine(),
QVideoFrame::imageFormatFromPixelFormat(replica.pixelFormat()) };
std::clog << replica.width() << " " << replica.height() << "\n";
std::clog << frame.width() << " " << frame.height() << "\n";
std::clog << image.width() << " " << image.height() << "\n";
std::clog << frame.pixelFormat() << "\n";
std::clog << QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat()) << "\n";
}
double dpi = QGuiApplication::primaryScreen()->physicalDotsPerInch();
auto pt_to_px = [dpi](double pt) -> double { return pt / 72 * dpi; };
auto px_to_pt = [dpi](double px) -> double { return px * 72 / dpi; };
std::clog << "12 pt is " << pt_to_px(12) << " px" << std::endl;
std::clog << "26 px is " << px_to_pt(26) << " pt" << std::endl;
QFont system_font;
std::clog << "system font size in pt: "
<< system_font.pointSize()
<< "\nsystem font size in px: "
<< pt_to_px(system_font.pointSize()) << std::endl;
LIBS += ./muParser/so/libmuparser.so
HEADERS += \
mainwindow.h \
./muParser/h/muParser.h \
./muParser/h/muParserBase.h \
./muParser/h/muParserBytecode.h \
./muParser/h/muParserCallback.h \
./muParser/h/muParserDef.h \
./muParser/h/muParserDLL.h \
./muParser/h/muParserError.h \
./muParser/h/muParserFixes.h \
./muParser/h/muParserInt.h \
./muParser/h/muParserStack.h \
./muParser/h/muParserTemplateMagic.h \
./muParser/h/muParserTest.h \
./muParser/h/muParserToken.h \
./muParser/h/muParserTokenReader.h
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/path_to_include_dir)
target_link_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/path_to_link_dir)
target_link_libraries(${PROJECT_NAME} PUBLIC libname)
#include <QtWidgets>
#include "widget.h"
int main(int argc, char *argv[])
{
QApplication ThisApp(argc,argv);
Widget ConverterWeights;
ConverterWeights.show();
return ThisApp.exec();
}
#ifndef WIDGET_H
#define WIDGET_H
#include <QtWidgets>
class Widget : public QWidget
{
Q_OBJECT
public:
QLabel *Title;
QLineEdit *Input;
QLineEdit *Output;
QComboBox *UnitWI;
QComboBox *UnitWO;
QPushButton *Button;
public:
Widget() : QWidget()
{
Title = new QLabel(this);
Input = new QLineEdit(this);
Output = new QLineEdit(this);
UnitWI = new QComboBox(this);
UnitWO = new QComboBox(this);
Button = new QPushButton(this);
ConfigBase();
ConfigTitle();
ConfigInput();
ConfigOutput();
ConfigUnitWI();
ConfigUnitWO();
ConfigButton();
QObject::connect(Button,SIGNAL(clicked(bool)),this,SLOT(PushButton()));
}
~Widget() {}
private:
void ConfigBase();
void ConfigTitle();
void ConfigInput();
void ConfigOutput();
void ConfigUnitWI();
void ConfigUnitWO();
void ConfigButton();
public slots:
void PushButton()
{
/*code*/
}
};
#endif
QLabel Title;
QLineEdit Input;
QLineEdit Output;
QComboBox UnitWI;
QComboBox UnitWO;
QPushButton Button;