当前位置: 首页>>代码示例>>C++>>正文


C++ QScreen::colorCount方法代码示例

本文整理汇总了C++中QScreen::colorCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QScreen::colorCount方法的具体用法?C++ QScreen::colorCount怎么用?C++ QScreen::colorCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScreen的用法示例。


在下文中一共展示了QScreen::colorCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: metric

int QWidget::metric(PaintDeviceMetric m) const
{
    Q_D(const QWidget);

    int val;
    if (m == PdmWidth) {
        val = data->crect.width();
    } else if (m == PdmWidthMM) {
        const QScreen *screen = d->getScreen();
        val = data->crect.width() * screen->physicalWidth() / screen->width();
    } else if (m == PdmHeight) {
        val = data->crect.height();
    } else if (m == PdmHeightMM) {
        const QScreen *screen = d->getScreen();
        val = data->crect.height() * screen->physicalHeight() / screen->height();
    } else if (m == PdmDepth) {
        return qwsDisplay()->depth();
    } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
        if (d->extra && d->extra->customDpiX)
            return d->extra->customDpiX;
        else if (d->parent)
            return static_cast<QWidget *>(d->parent)->metric(m);
        const QScreen *screen = d->getScreen();
        return qRound(screen->width() / double(screen->physicalWidth() / 25.4));
    } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
        if (d->extra && d->extra->customDpiY)
            return d->extra->customDpiY;
        else if (d->parent)
            return static_cast<QWidget *>(d->parent)->metric(m);
        const QScreen *screen = d->getScreen();
        return qRound(screen->height() / double(screen->physicalHeight() / 25.4));
    } else if (m == PdmNumColors) {
        QScreen *screen = d->getScreen();
        int ret = screen->colorCount();
        if (!ret) {
            const int depth = qwsDisplay()->depth();
            switch (depth) {
            case 1:
                ret = 2;
                break;
            case 8:
                ret = 256;
                break;
            case 16:
                ret = 65536;
                break;
            case 24:
                ret = 16777216;
                break;
            case 32:
                ret = 2147483647;
                break;
            }
        }
        return ret;
    } else {
        val = QPaintDevice::metric(m);// XXX
    }
    return val;
}
开发者ID:Afreeca,项目名称:qt,代码行数:60,代码来源:qwidget_qws.cpp


注:本文中的QScreen::colorCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。