微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > CentOS64+Qt+Mysql+ftp+无密钥传输的配置详细过程

CentOS64+Qt+Mysql+ftp+无密钥传输的配置详细过程

时间:10-08 来源:互联网 点击:

  1. LIBRARY_PATH=$QTDIR/lib:$LIBRARY_PATH

    QMAKESPEC=$QTDIR/mkspecs/linux-g++-64

    export QTDIR

    export PATH

    export LD_LIBRARY_PATH

    export QMAKESPEC

    ## 查看Qt支持的图片类型

    可以运行下面的函数查看:QImageReader::supportedImageFormats

    QList QImageReader::supportedImageFormats () [static]

    Returns the list of image formats supported by QImageReader.

    By default, Qt can read the following formats:

    Format Description

    BMP Windows Bitmap

    GIF Graphic Interchange Format (optional)

    JPG Joint Photographic Experts Group

    JPEG Joint Photographic Experts Group

    MNG Multiple-image Network Graphics

    PNG Portable Network Graphics

    PBM Portable Bitmap

    PGM Portable Graymap

    PPM Portable Pixmap

    TIFF Tagged Image File Format

    XBM X11 Bitmap

    XPM X11 Pixmap

    SVG Scalable Vector Graphics

    TGA Targa Image Format

    Reading and writing SVG files is supported through Qt's SVG Module.

    TGA support only extends to reading non-RLE compressed files. In particular calls to capabilities for the tga plugin returns only QImageIOPlugin::CanRead, not QImageIOPlugin::CanWrite.

    To configure Qt with GIF support, pass -qt-gif to the configure script or check the appropriate option in the graphical installer.

    Note that the QApplication instance must be created before this function is called.

    See also setFormat(), QImageWriter::supportedImageFormats(), and QImageIOPlugin.

    ############################################################################################

    # 4. 使用Qt连接Mysql

    ############################################################################################

    #include

    #include

    #include

    #include

    using namespace std;

    int main(int argc, char *argv[])

    {

    QApplication app(argc, argv);

    QSqlDatabase db = QSqlDatabase::addDatabase(QMYSQL);

    db.setHostName(localhost);

    db.setDatabaseName(mydb);

    db.setUserName(username);

    db.setPassword(password);

    db.open();

    QSqlQuery query;

    query.exec(create table hello(id bigint not null auto_increment,name varchar(255),age bigint,primary key (id)));

    query.exec(insert into hello(name, age) values('xiaoxi', 18));

    query.exec(insert into hello(name, age) values('xiaonan', 19));

    query.exec(insert into hello(name, age) values('xiaobei', 20));

    query.exec(insert into hello(name, age) values('xiaodong', 21));

    QSqlQueryModel *model = new QSqlQueryModel;

    model->setQuery(select * from hello);

    model->setHeaderData(0, Qt::Horizontal, id);

    model->setHeaderData(1, Qt::Horizontal, name);

    model->setHeaderData(2, Qt::Horizontal, age);

    QTableView *view = new QTableView;

    view->setWindowTitle(QSqlQueryModel);

    view->setModel(model);

    view->show();

    db.close();

    return app.exec();

    }

    编译:

    xhy@xhy-desktop:~$ qmake -project

    xhy@xhy-desktop:~$ qmake

    一定别忘了在工程的.pro文件里加上下面一行:

    QT += sql

    xhy@xhy-desktop:~$make

    xhy@xhy-desktop:~$./mysql

    ############################################################################################

    # 5. CentOS配置sftp

    ############################################################################################

    sftp是ssh内含的协议,只要sshd服务器启动了,它就可用.

    sftp root@192.168.2.18

    >ls

    >get ...

    >put ...

    如果sshd服务没有默认启动:

    chkconfig sshd on

    ############################################################################################

    # 6. CentOS配置无密钥传输

    ############################################################################################

    # 举例说明:

    [root@centos6-64 .ssh]# pwd

    /root/.ssh

    [root@centos6-64 .ssh]# ssh-keygen

    Generating public/private rsa key pair.

    Enter file in which to save the key (/root/.ssh/id_rsa):

    Enter passphrase (empty for no passphrase):

    Enter same passphrase again:

    Your identification has been saved in /root/.ssh/id_rsa.

    Your public key has been saved in /ro

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top