乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      QT顯示圖片 共兩大類方法

       cjavahtml 2016-04-27
        QT顯示圖片的方法有很多

        大致為

        label上顯示

        直接畫出來

        1-------------------------label上顯示圖片------------------

        把你的label.png放到工程目錄頂層,直接

        QPixmap pixmap('label.png');

        ui->title_label->setPixmap(pixmap);

        ui->title_label->show();

        ---

        可以直接:

        label->setPixmap(QPixmap('./pic.jpg'));

        或者:

        QImage *image= new QImage('./pic.jpg');

        label->setPixmap(QPixmap::fromImage(image));

        再或者在中途換某個圖像的話:

        QImage *image= new QImage('./pic1.jpg');

        label->setPixmap(QPixmap::fromImage(image));

        ...........

        image->load('./pic2.jpg');


        2----------直接畫出圖片-------------------------

        voidlogindlg::paintEvent(QPaintEvent*)
       {
      QPainterpainter(this);
      QPixmappix;pix.load('D:/QT/login/login/images/delta.png');
      painter.drawPixmap(0,0,100,33,pix);
      //painter.drawLine(0,0,100,100);
      }




        最后補充-----------程序啟動時的圖片

        QApplication app(argc, argv);

        QSplashScreen *splash = new QSplashScreen;

        splash->setPixmap(QPixmap(':/images/splash.png'));//設置圖片

        splash->show();//顯示圖片

        Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;

        splash->showMessage(QObject::tr('Setting up the main window...'),topRight, Qt::white);//顯示信息

        MainWindow mainWin;

        splash->showMessage(QObject::tr('Loading modules...'),

        topRight, Qt::white); //顯示信息

        loadModules();

        splash->showMessage(QObject::tr('Establishing connections...'),

        topRight, Qt::white); //顯示信息

        establishConnections();

        mainWin.show();

        splash->finish(&mainWin);//圖片一直顯示到mainWin加載完成

        delete splash;//釋放空間,節(jié)省內存

        return app.exec();

        來自: http://hi.baidu.com/sdink/blog/item/879e7013027a7fcaa7ef3f83.html

        首先你得加載一張能顯示透明的圖片,jpg格式肯定是不行的,一般都是png

        還有不同的部件加載圖片的方法也不太相同,比如:

        QLabel加載圖片:

        C/C++ code

        QString strPath=imagePath.value(day); //圖片路徑

        QPixmap pix(strPath);

        dayLabel->setPixmap(pix);

        QPushButton加載圖片:

        C/C++ code

        button->setIcon(QIcon('toolbutton.png'));

        button->setIconSize(QSize(48, 48));

        其中setIconSize函數是用來截取圖片的顯示區(qū)域,如果沒有該函數,該圖片是被縮放的放到圖片上

        用調色板加載圖片:

        C/C++ code

        QPalette p = palette();

        p.setBrush(QPalette::Button, QBrush(QPixmap('toolbutton.png')));

        setPalette(p);

        另外實現(xiàn)按鈕的透明:

        C/C++ code

        button->setFlat(true);

        還有就是用繪制事件函數了:

        C/C++ code

        QPixmap arrayImage('/home/image/array.png'); //圖片路徑

        QRect arrayRect(0,0,50,50); //截取圖片區(qū)域

        QPainter painter;

        painter.drawPixmap(QPoint(100,100),arrayImage,arrayRect); //打印圖片

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多