• QT 随笔


    


    1. 设置窗体属性,无边框 | 置顶
    setWindowFlags(Qt::FramelessWindowHint);
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);

    2. 槽-信号机制中用到自己定义数据类型:

    class MyTest
    {
    };
    class MyThread: public QThread
    {
     Q_OBJECT
    signals:
     void thesignal(bool noerror, const MyTest& MyTest);
     
    public:
     virtual void run(); 
    };

    除Q_OBJECT。须要加:
    qRegisterMetaType<MyTest>("MyTest");

    3. 槽函数中通过“QObject::sender()”获取谁发送的信号
    QCheckBox* Chb = dynamic_cast<QCheckBox*>(QObject::sender());

    4. Radio button 状态以图片方式显示
    QString style = "QRadioButton { spacing: 5px; } QRadioButton::indicator{ 24px;height: 24px;}QRadioButton::indicator:unchecked{    image:url(:/radiobutton_off);}QRadioButton::indicator:checked{  image:url(:/radiobutton_on);} ";
    ui.onceRadioBtn->setStyleSheet(style);
    对checkbox控件也适用

    5. 改变字体,能够直接使用windows下字体
    Application theApp(argc, argv); 
    theApp.setFont(QFont("simsun", 11));

    6. 获取mac,ip
    /* Get all interface (IP / Mask / MAC) */
    QNetworkInterface InterfaceEth0 = QNetworkInterface::interfaceFromName("eth0");
    QString mac = InterfaceEth0.hardwareAddress();
    foreach(QNetworkAddressEntry addressE , InterfaceEth0.addressEntries()) {
     if(addressE.ip().protocol() == QAbstractSocket::IPv4Protocol &&
      addressE.broadcast() != QHostAddress::Null) {
       QString IP = addressE.ip().toString();
       QString Mask = addressE.netmask().toString();
       break;
     }
    }

    /* 获取全部网络接口 */
    QList<QNetworkInterface> InterfaceEthList = QNetworkInterface::allInterfaces();


  • 相关阅读:
    centos 6 升级gcc
    linux fdisk 分区
    centos使用163的源
    工作流发布成功但不能自动启动
    可怕的断电
    FTP 之 550 permission denied
    Track & Trace
    AutoKey思想的應用(二)
    Windows登錄過程淺析
    snapshot.exe出現異常
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/6999560.html
Copyright © 2020-2023  润新知