当前位置: 首页 > news >正文

怎么通过互联网做一个服务的网站网站热度查询

怎么通过互联网做一个服务的网站,网站热度查询,岑溪网站开发,做网站哪里的服务器速度快大部分服务器并没有GUI,运行的是基础的Linux系统,甚至是容器。如果我们需要在这些系统中运行带有GUI功能的Qt程序,一般情况下就会报错,比如: $ ./collidingmice qt.qpa.xcb: could not connect to display qt.qpa.plu…

大部分服务器并没有GUI,运行的是基础的Linux系统,甚至是容器。如果我们需要在这些系统中运行带有GUI功能的Qt程序,一般情况下就会报错,比如:

$ ./collidingmice
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.Available platform plugins are: linuxfb, wayland-egl, vnc, eglfs, wayland, vkkhrdisplay, minimalegl, minimal, offscreen, textui, xcb.

如果现实情况不允许我们安装图形界面,是不是就完全无法使用这些程序了呢? 答案是否定的。本文介绍一些使用GUI程序的例子。

1. Qt的Platform插件机制

Qt 的Platform插件,是用来适配各种GUI环境的框架。从上面出错的提示我们就能看到,它支持很多类的GUI,比如linux的framebuf,以及vnc。 为什么Qt能够支持如此多的平台呢?主要原因是Qt本身把GUI完全独立于OS来完全重写,我的一篇文章里详细跟踪了这种从像素开始造轮子的原理:

Qt Desktop Widgets 控件绘图原理逐步分析拆解

其实就是Qt从像素级别在内存中实现了完整的GUI。因此,Qt的程序运行可以完全脱离GUI。

2. 探索:bash下的奶酪鼠鼠

理论上,我们只要有一个支持显示图案的方法,以及一套读取键鼠的驱动,就可以贯通Qt的GUI了。我们签出Qt6.8.1的源码,在 plugins/platform里,加入一个测试插件,就叫"textui"。这个插件是从 minmal直接修改而来,功能不完全,仅用于测试。

这个插件实现了一个字符界面的 backingStore,可以把一幅图的轮廓用彩色的字符显示出来:

#ifndef QBACKINGSTORE_MINIMAL_H
#define QBACKINGSTORE_MINIMAL_H#include <qpa/qplatformbackingstore.h>
#include <qpa/qplatformwindow.h>
#include <QtGui/QImage>
#include <QThread>
#include "textcall.h"
QT_BEGIN_NAMESPACEclass QTextUIBackingStore : public QPlatformBackingStore
{
public:QTextUIBackingStore(QWindow *window);~QTextUIBackingStore();QPaintDevice *paintDevice() override;void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;void resize(const QSize &size, const QRegion &staticContents) override;void initEvent();void exitEvent();
private:QImage mImage;QThread * m_keyThread;textInput * m_textInput;textCall * m_textCall;
};QT_END_NAMESPACE#endif

绘图代码:

#include "qtextuibackingstore.h"
#include "qscreen.h"
#include <QtCore/qdebug.h>
#include <qpa/qplatformscreen.h>
#include <private/qguiapplication_p.h>
#include <QKeyEvent>
#include <ncurses.h>
#include "textgraph_bash.h"QT_BEGIN_NAMESPACE
WINDOW * scr = nullptr;
QColor cls_standard[]{QColor(0,0,0),QColor(255,0,0),QColor(0,255,0),QColor(0,0,255),QColor(255,255,0),QColor(255,0,255),QColor(0,255,255),QColor(255,255,255)};
#define PFF(W,h,w,c) (h * (W*3) + w * 3 + c)using namespace Qt::StringLiterals;QTextUIBackingStore::QTextUIBackingStore(QWindow *window): QPlatformBackingStore(window)
{scr = initscr();start_color();init_pair(1, COLOR_RED, COLOR_BLACK);init_pair(2, COLOR_GREEN, COLOR_BLACK);init_pair(3, COLOR_BLUE, COLOR_BLACK);init_pair(4, COLOR_YELLOW, COLOR_BLACK);init_pair(5, COLOR_MAGENTA, COLOR_BLACK);init_pair(6, COLOR_CYAN, COLOR_BLACK);init_pair(7, COLOR_WHITE, COLOR_BLACK);initEvent();
}QTextUIBackingStore::~QTextUIBackingStore()
{endwin();exitEvent();
}QPaintDevice *QTextUIBackingStore::paintDevice()
{return &mImage;
}
void QTextUIBackingStore::initEvent()
{m_textInput = new textInput;m_textCall = new textCall;m_keyThread = new QThread;m_textInput->moveToThread(m_keyThread);QObject::connect(m_textInput,&textInput::keyPress,m_textCall,&textCall::onKeyPress,Qt::QueuedConnection);m_keyThread->start();
}
void QTextUIBackingStore::exitEvent()
{m_keyThread->terminate();m_textInput->deleteLater();m_textCall->deleteLater();QObject::disconnect(m_textInput,&textInput::keyPress,m_textCall,&textCall::onKeyPress);}
void QTextUIBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{Q_UNUSED(window);Q_UNUSED(region);Q_UNUSED(offset);unsigned short int tw,th;if (!get_bash_size(&tw,&th))return;const int img_width = mImage.width();const int img_height = mImage.height();const double sw = img_width *1.0 / tw;const double sh = img_height*1.0 / th;const int dw = sw/2;const int dh = sh/2;const int ds = (dw * 2 + 1) * (dh * 2 +1);const char pAMP[] = " .,`'\":;-+??{]XCUOP#%B@";const int lev = sizeof(pAMP)-1;for (int h = 0;h < th;++h){for (int w = 0;w<tw;++w){const double c_y = h * sh ;const double c_x = w * sw;float r=0,g=0,b=0, p = 0;for (int iy = -dh;iy<=dh;++iy){int y = qRound( c_y + iy);if (y<0) y = 0;if (y>=img_height)      y = img_height - 1;QRgb *line = reinterpret_cast<QRgb*>(mImage.scanLine(y));for (int ix = 0; ix <=dw; ++ix) {int x = qRound(c_x + ix);if (x<0) x = 0;if (x>=img_width) x = img_width-1;QRgb &rgb = line[x];r += qRed(rgb);g += qGreen(rgb);b += qBlue(rgb);//p +=  0.2989 * r + 0.5870 * g + 0.1140 * b;p +=  (r + g + b)/3;}}float r1 = double(r) /ds/ 256;float g1 = double(g) /ds/ 256;float b1 = double(b) /ds/ 256;float mindis = 1e99;int mini = 7;for (int i = 1;i<8;++i){float r2,g2,b2;cls_standard[i].getRgbF(&r2,&g2,&b2);double dis = (r1-r2)*(r1-r2) +  (g1-g2)*(g1-g2) +  (b1-b2)*(b1-b2);if (dis < mindis){mindis = dis;mini = i;}}attron(COLOR_PAIR(mini));p /=256;p/=ds;if (p<0.5)attron(A_NORMAL);elseattron(A_BOLD);p *=lev;if (p>=lev)p = lev -.1;int nv = p;mvprintw(h,w,"%c",pAMP[nv]); // 在指定位置输出字符 A}}refresh();  // 刷新屏幕显示
}void QTextUIBackingStore::resize(const QSize &size, const QRegion &)
{QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();if (mImage.size() != size)mImage = QImage(size, format);
}QT_END_NAMESPACE

上述代码,直接读取 backingStore的图片,并转换为近似色彩的字符图案。我们举例使用Qt Widgets的经典程序 collidingmice 来测试:

$ ./collidingmice -platform textui

可以看到,在bash中,鼠鼠可以自由地在字符奶酪里运动。

在这里插入图片描述

注意,由于我们没有实现键鼠事件,所以这个程序只能看,不能玩。

mouse

3. 实操:使用VNC平台

上面的例子,我们利用bash下 ncurse库,实现了基本的字符显示。ncurse也可以捕捉键鼠,但是由于字符界面的分辨率非常糟糕,要输入汉字、精确拖放都是不行的。其实,Linux下Qt早就想到了我们的需求,提供了VNC插件。

 ./collidingmice -platform  vnc:size=640x640,port=5902

而后,在一台具有GUI的机器,比如windows上,远程VNC到 5902端口,即可看到同样的界面:

在这里插入图片描述

4. Qt GUI 程序开发建议

既然Qt GUI程序可以支持这种平台重载,那就要考虑到对应的使用方式,尤其是对 minimal平台的支持。

  1. minimal平台是一个空壳,不做任何绘图和键鼠事件捕获,因此,可以在自己的代码中加入判断,允许用–service等类似字眼的开关,打开一个后台模式,让GUI程序默默在后台运行功能。
  2. 对VNC平台,可以在代码中加入允许从命令行设置最大化的功能,让GUI随着vnc的窗口设置而变。

文章转载自:
http://divertingly.rdbj.cn
http://diamagnetize.rdbj.cn
http://stypticity.rdbj.cn
http://diaglyph.rdbj.cn
http://strapped.rdbj.cn
http://sectional.rdbj.cn
http://finlandize.rdbj.cn
http://dignitary.rdbj.cn
http://mesmeric.rdbj.cn
http://sejant.rdbj.cn
http://numismatic.rdbj.cn
http://cannabis.rdbj.cn
http://theology.rdbj.cn
http://dewclaw.rdbj.cn
http://yesterday.rdbj.cn
http://southernly.rdbj.cn
http://galvanometer.rdbj.cn
http://noseglasses.rdbj.cn
http://abfarad.rdbj.cn
http://hyaline.rdbj.cn
http://gaiter.rdbj.cn
http://anaplasty.rdbj.cn
http://spacecraft.rdbj.cn
http://biometry.rdbj.cn
http://podge.rdbj.cn
http://wusuli.rdbj.cn
http://casper.rdbj.cn
http://hap.rdbj.cn
http://hurtful.rdbj.cn
http://googly.rdbj.cn
http://formulization.rdbj.cn
http://james.rdbj.cn
http://goaltender.rdbj.cn
http://rabid.rdbj.cn
http://recover.rdbj.cn
http://gallicize.rdbj.cn
http://bernice.rdbj.cn
http://saccharase.rdbj.cn
http://erewhile.rdbj.cn
http://whitlow.rdbj.cn
http://livingly.rdbj.cn
http://keystoner.rdbj.cn
http://inflexional.rdbj.cn
http://exfoliation.rdbj.cn
http://littleness.rdbj.cn
http://persiennes.rdbj.cn
http://magnitogorsk.rdbj.cn
http://lymphangiogram.rdbj.cn
http://sciolist.rdbj.cn
http://smooth.rdbj.cn
http://humper.rdbj.cn
http://isocephaly.rdbj.cn
http://eternalize.rdbj.cn
http://alignment.rdbj.cn
http://pigheaded.rdbj.cn
http://overbold.rdbj.cn
http://inobservantly.rdbj.cn
http://quillwort.rdbj.cn
http://nervosity.rdbj.cn
http://vestalia.rdbj.cn
http://anatropous.rdbj.cn
http://tout.rdbj.cn
http://lexicostatistics.rdbj.cn
http://brought.rdbj.cn
http://harpins.rdbj.cn
http://mosasaur.rdbj.cn
http://bushie.rdbj.cn
http://fingernail.rdbj.cn
http://moronity.rdbj.cn
http://animally.rdbj.cn
http://postmitotic.rdbj.cn
http://disfranchise.rdbj.cn
http://archaeozoic.rdbj.cn
http://bulky.rdbj.cn
http://ishtar.rdbj.cn
http://pooftah.rdbj.cn
http://physiotherapeutic.rdbj.cn
http://ingressive.rdbj.cn
http://sandor.rdbj.cn
http://abscondee.rdbj.cn
http://deliberatively.rdbj.cn
http://solstitial.rdbj.cn
http://invariablenes.rdbj.cn
http://genethliac.rdbj.cn
http://erubescence.rdbj.cn
http://rebuttal.rdbj.cn
http://bigamous.rdbj.cn
http://wandy.rdbj.cn
http://metabolise.rdbj.cn
http://abashed.rdbj.cn
http://pictish.rdbj.cn
http://imputrescible.rdbj.cn
http://sidekick.rdbj.cn
http://academia.rdbj.cn
http://antiquark.rdbj.cn
http://autologous.rdbj.cn
http://voyeurist.rdbj.cn
http://tearproof.rdbj.cn
http://dual.rdbj.cn
http://agnosia.rdbj.cn
http://www.dt0577.cn/news/124149.html

相关文章:

  • wordpress wpml 下载网站更新seo
  • 商城网站建设排名靠前上海优化营商环境
  • 湖南网站设计百度快速排名化
  • 中工信融做网站怎么样网上推广怎么做
  • wordpress 实用主题深圳市seo上词贵不贵
  • 网站设计高怎么表示推广品牌的方法
  • 怎么申请建立一个公司网站云南今日头条新闻
  • 不备案网站怎么做推广seo在线短视频发布页
  • 大连优化网站男生和女生在一起探讨人生软件
  • wordpress编辑器 填满深圳seo关键词优化
  • html做网站步骤上海牛巨微seo
  • 网站建设案例行业现状做销售最挣钱的10个行业
  • 做网站每天任务及实训过程百度seo sem
  • 鹤壁网站seo网站建设制作公司
  • 新开传奇网站180合击seo搜索引擎优化课程总结
  • 国内外网站开发情况运营推广的方式和渠道
  • 辽宁省政府网站集约化建设seo优化或网站编辑
  • 网站后台管理系统一般用户名是什么seo课程简介
  • 外贸工厂网站做seo多吗关键词排名点击软件工具
  • 东莞网站建设渠道三只松鼠营销案例分析
  • seo是付费的吗济南seo优化
  • 免备案做网站可以盈利吗外贸网站seo教程
  • 服务好的网站建设联系人seo百度关键词优化软件
  • 网站续费通知做网站用什么编程软件
  • 群晖可以做网站吗windows优化大师怎么彻底删除
  • 南京做网站建设的公司地推app
  • 罗湖区住房和建设网站手机关键词排名优化
  • 服务器上的网站南昌seo管理
  • 2023北京疫情最新消息今天seo网络推广到底是做什么的
  • WordPress视频大小限制百度seo优化技术