• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pixmap函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pixmap函数的典型用法代码示例。如果您正苦于以下问题:C++ pixmap函数的具体用法?C++ pixmap怎么用?C++ pixmap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    dal_main = new DAL_main(this);
    QCoreApplication::setApplicationName("pocskaf2");
    QCoreApplication::setOrganizationName("team2");
    QSettings prevSettings("team2", "pocskaf2");
    if (prevSettings.value("databaseName").isNull() || prevSettings.value("port").isNull() || prevSettings.value("username").isNull() || prevSettings.value("password").isNull() || prevSettings.value("host").isNull())
    {
        accessdb *access = new accessdb(this);
        access->marker = 1;
        access->exec();
    }
    else
    {
        if( dal_main->setConnection(prevSettings.value("databaseName").toString(),prevSettings.value("port").toInt(),prevSettings.value("host").toString(),prevSettings.value("username").toString(),prevSettings.value("password").toString()))
        {
            QMessageBox::information(this, tr("Соединение успешно"), tr("Соединение с базой данных установлено"));
        }
        else
        {
            QMessageBox::critical(this, tr("Ошибка подключения"), tr("Соединение с базой данных невозможно"));
            accessdb *access = new accessdb(this);
            access->marker = 1;
            access->exec();
        }
    }
    Authorization *w=new Authorization(this) ;
    w->setWindowFlags(Qt::Dialog | Qt::Desktop);
    w->exec();

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    timer->start(1000);
    showTime();

    QPixmap pixmap(":/img/img/pocs2.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    QFont splashFont;
    splashFont.setPixelSize(17);
    splash->setFont(splashFont);
    splash->show();
    QTime time;
    time.start();
    for (int i = 0; i < 100; )
    {
        if (time.elapsed() > 5)
        {
            time.start();
            ++i;
        }
        splash->showMessage(tr("     Загрузка системы: ") + QString::number(i) + "%", Qt::AlignLeft | Qt::AlignBottom , Qt::black);
        QCoreApplication::processEvents();
    }

    QSqlQuery * empNameQuery = new QSqlQuery(dal_main->db);
    empNameQuery->prepare("SELECT st_fio, st_photo FROM is_sotrudniki where id_sotr = " + QString::number(dal_main->getCurrentEmployee()));
    empNameQuery->exec();
    empNameQuery->first();
    if(empNameQuery->isValid())
        this->setWindowTitle("SMT v. 1.0 (текущий пользователь - " + empNameQuery->value(0).toString() + ")");


    checkNaznPoruch = new QSqlQuery(dal_main->db);
    checkNaznPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where  checkPoruch = 0 and poruchitel = " + QString::number(dal_main->getCurrentEmployee()));
    checkIspolPoruch = new QSqlQuery(dal_main->db);
    checkIspolPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where  checkIspoln = 0 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee()));
    checker = new QTimer;
    //        checkDatePoruch = new QSqlQuery(dal_main->db);
    //        checkDatePoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where check_date  and checkIspoln = 1 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee()));
    connect(checker,SIGNAL(timeout()),this,SLOT(on_check()));
    checker->setInterval(10000);
    checker->start();
    icon = new QSystemTrayIcon(this);
    icon->setIcon(QIcon(":/img/img/institution_icon.png"));
    icon->show();
    //icon->setContextMenu(ui->menu_file);
    connect(icon,SIGNAL(messageClicked()),this,SLOT(on_actionChecks())); //Open form Request

    ui->pushButton_show->setVisible(false);
    ui->pushButton_show->setFlat(true);
    ui->pushButton_hide->setFlat(true);
    ui->groupBox_main->setContentsMargins(0,0,0,0);
    ui->mdiArea->setVisible(false);
    QGraphicsDropShadowEffect * ef1 =  new QGraphicsDropShadowEffect;
    ef1->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef2 =  new QGraphicsDropShadowEffect;
    ef2->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef3 =  new QGraphicsDropShadowEffect;
    ef3->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef4 =  new QGraphicsDropShadowEffect;
    ef4->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef5 =  new QGraphicsDropShadowEffect;
    ef5->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef6 =  new QGraphicsDropShadowEffect;
    ef6->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef7 =  new QGraphicsDropShadowEffect;
    ef7->setBlurRadius(15);
//.........这里部分代码省略.........
开发者ID:kanbodows,项目名称:kafpocs,代码行数:101,代码来源:mainwindow.cpp


示例2: QImage

QImage QRImageWidget::exportImage()
{
    if(!pixmap())
        return QImage();
    return pixmap()->toImage().scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE);
}
开发者ID:seraph1188,项目名称:darcoin,代码行数:6,代码来源:receiverequestdialog.cpp


示例3: contextMenuEvent

void QRImageWidget::contextMenuEvent(QContextMenuEvent *event)
{
    if(!pixmap())
        return;
    contextMenu->exec(event->globalPos());
}
开发者ID:seraph1188,项目名称:darcoin,代码行数:6,代码来源:receiverequestdialog.cpp


示例4: pixmap

void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
{
    painter->drawPixmap(rect, pixmap(rect.size(), mode, state));
}
开发者ID:fluxer,项目名称:katie,代码行数:4,代码来源:qicon.cpp


示例5: main


//.........这里部分代码省略.........
	bool commandLine = (argc > 1 && argv[1][0] == '-');
	
	//specific case: translation file selection
	int lastArgumentIndex = 1;
	QTranslator translator;
	if (commandLine && QString(argv[1]).toUpper() == "-LANG")
	{
		QString langFilename = QString(argv[2]);
		
		//Load translation file
		if (translator.load(langFilename, QCoreApplication::applicationDirPath()))
		{
			qApp->installTranslator(&translator);
		}
		else
		{
			QMessageBox::warning(0, QObject::tr("Translation"), QObject::tr("Failed to load language file '%1'").arg(langFilename));
		}
		commandLine = false;
		lastArgumentIndex = 3;
	}

	//command line mode
	if (!commandLine)
	{
		if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) == 0)
		{
			QMessageBox::critical(0, "Error", "This application needs OpenGL 2.1 at least to run!");
			return EXIT_FAILURE;
		}

		//splash screen
		splashStartTime.start();
		QPixmap pixmap(QString::fromUtf8(":/CC/images/imLogoV2Qt.png"));
		splash = new QSplashScreen(pixmap, Qt::WindowStaysOnTopHint);
		splash->show();
		QApplication::processEvents();
	}

	//global structures initialization
	ccTimer::Init();
	FileIOFilter::InitInternalFilters(); //load all known I/O filters (plugins will come later!)
	ccNormalVectors::GetUniqueInstance(); //force pre-computed normals array initialization
	ccColorScalesManager::GetUniqueInstance(); //force pre-computed color tables initialization

	int result = 0;

	if (commandLine)
	{
		//command line processing (no GUI)
		result = ccCommandLineParser::Parse(argc, argv);
	}
	else
	{
		//main window init.
		MainWindow* mainWindow = MainWindow::TheInstance();
		if (!mainWindow)
		{
			QMessageBox::critical(0, "Error", "Failed to initialize the main application window?!");
			return EXIT_FAILURE;
		}
		mainWindow->show();
		QApplication::processEvents();

		//show current Global Shift parameters in Console
		{
开发者ID:TJC-AS,项目名称:trunk,代码行数:67,代码来源:main.cpp


示例6: pixmap

void AboutDialog::setLogo(const QString filename)
{
    QPixmap pixmap(filename);
    label_Logo->setPixmap(pixmap);

}
开发者ID:alemic,项目名称:WebKugou,代码行数:6,代码来源:aboutdialog.cpp


示例7: QTableView

listMemberDialog::listMemberDialog(QWidget *parent,QString classId)
{
	conn = database::connectByC();
	QVBoxLayout *topLeftLayout = new QVBoxLayout;

	view  = new QTableView(this);
	model = new QStandardItemModel(this);
	view->setModel(model);

	model->setHorizontalHeaderItem(0, new QStandardItem(tr("ID")));
	model->setHorizontalHeaderItem(1, new QStandardItem(tr("Name")));
	model->setHorizontalHeaderItem(2, new QStandardItem(tr("Birth year")));
	model->setHorizontalHeaderItem(3, new QStandardItem(tr("Note")));
	model->setHorizontalHeaderItem(4, new QStandardItem(tr("-")));
	
	view->setColumnWidth(0,20);
	view->setColumnWidth(1,90);
	view->setColumnWidth(2,57);
	view->setColumnWidth(3,40);
	view->setColumnWidth(4,30);
	
	label = new QLabel("Member list");
	topLeftLayout->addWidget(label);
	int rowCurrent = 0;

	MYSQL_RES *res = database::classMember_searchClassId(conn,classId);
	while(MYSQL_ROW classMemberRow = mysql_fetch_row(res))
	{
		QString memberId   = classMemberRow[1];
		MYSQL_ROW memberRow = database::member_searchMemberId(conn,memberId);
		
		model->setItem(rowCurrent, 0, new QStandardItem(memberRow[0]));
		model->setItem(rowCurrent, 1, new QStandardItem(memberRow[1]));
		model->setItem(rowCurrent, 2, new QStandardItem(memberRow[2]));
		model->setItem(rowCurrent, 3, new QStandardItem(memberRow[3]));

		QPushButton *button = new QPushButton("");
		QPixmap pixmap("Resources/Delete_icon.png");
		QIcon buttonIcon(pixmap);
		button->setIcon(buttonIcon);
		QSignalMapper *signalMapper = new QSignalMapper(this);
		signalMapper->setMapping(button,memberId);
		QObject::connect(button,SIGNAL(clicked()),signalMapper,SLOT(map()));
		QObject::connect(signalMapper,SIGNAL(mapped(QString)),this,SLOT(deleteMemberAction(QString)));
		view->setIndexWidget(model->index(rowCurrent,4),button);

		rowCurrent++;
	}
	numOldMemberInDialog = rowCurrent;
	topLeftLayout->addWidget(view);

	QHBoxLayout *horizontalLayout = new QHBoxLayout();
	QPushButton *saveButton = new QPushButton("Save");
	QPixmap pixmap1("Resources/save_icon.png");
	QIcon ButtonIcon1(pixmap1);
	saveButton->setIcon(ButtonIcon1);
	QSignalMapper *saveMapper = new QSignalMapper(this);
	saveMapper->setMapping(saveButton,classId);
	QObject::connect(saveButton,SIGNAL(clicked()),saveMapper,SLOT(map()));
	QObject::connect(saveMapper,SIGNAL(mapped(QString)),this,SLOT(saveListAction(QString)));
	
	horizontalLayout->addWidget(saveButton);
	
	QPushButton *addMemberButton = new QPushButton("Add Member");
	QPixmap pixmap("Resources/add-icon.png");
	QIcon ButtonIcon(pixmap);
	addMemberButton->setIcon(ButtonIcon);
	QObject::connect(addMemberButton,SIGNAL(clicked()),this,SLOT(addMemberAction()));
	horizontalLayout->addWidget(addMemberButton);

	setLayout(topLeftLayout);
	topLeftLayout->addLayout(horizontalLayout);
	setWindowTitle(tr("Member list"));
	setFixedHeight(sizeHint().height());
	
}
开发者ID:ndaonguyen,项目名称:QT_EnglishCourse,代码行数:76,代码来源:listMemberDialog.cpp


示例8: Q_FOREACH

/** @short Reimplemented to show custom pixmap during drag&drop

  Qt's model-view classes don't provide any means of interfering with the
  QDrag's pixmap so we just rip off QAbstractItemView::startDrag and provide
  our own QPixmap.
*/
void MsgListView::startDrag(Qt::DropActions supportedActions)
{
    // indexes for column 0, i.e. subject
    QModelIndexList baseIndexes;

    Q_FOREACH(const QModelIndex &index, selectedIndexes()) {
        if (!(model()->flags(index) & Qt::ItemIsDragEnabled))
            continue;
        if (index.column() == Imap::Mailbox::MsgListModel::SUBJECT)
            baseIndexes << index;
    }

    if (!baseIndexes.isEmpty()) {
        QMimeData *data = model()->mimeData(baseIndexes);
        if (!data)
            return;

        // use screen width and itemDelegate()->sizeHint() to determine size of the pixmap
        int screenWidth = QApplication::desktop()->screenGeometry(this).width();
        int maxWidth = qMax(400, screenWidth / 4);
        QSize size(maxWidth, 0);

        // Show a "+ X more items" text after so many entries
        const int maxItems = 20;

        QStyleOptionViewItem opt;
        opt.initFrom(this);
        opt.rect.setWidth(maxWidth);
        opt.rect.setHeight(itemDelegate()->sizeHint(opt, baseIndexes.at(0)).height());
        size.setHeight(qMin(maxItems + 1, baseIndexes.size()) * opt.rect.height());
        // State_Selected provides for nice background of the items
        opt.state |= QStyle::State_Selected;

        // paint list of selected items using itemDelegate() to be consistent with style
        QPixmap pixmap(size);
        pixmap.fill(Qt::transparent);
        QPainter p(&pixmap);

        for (int i = 0; i < baseIndexes.size(); ++i) {
            opt.rect.moveTop(i * opt.rect.height());
            if (i == maxItems) {
                p.fillRect(opt.rect, palette().color(QPalette::Disabled, QPalette::Highlight));
                p.setBrush(palette().color(QPalette::Disabled, QPalette::HighlightedText));
                p.drawText(opt.rect, Qt::AlignRight, tr("+ %n additional item(s)", 0, baseIndexes.size() - maxItems));
                break;
            }
            itemDelegate()->paint(&p, opt, baseIndexes.at(i));
        }

        QDrag *drag = new QDrag(this);
        drag->setPixmap(pixmap);
        drag->setMimeData(data);
        drag->setHotSpot(QPoint(0, 0));

        Qt::DropAction dropAction = Qt::IgnoreAction;
        if (defaultDropAction() != Qt::IgnoreAction && (supportedActions & defaultDropAction()))
            dropAction = defaultDropAction();
        else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
            dropAction = Qt::CopyAction;
        if (drag->exec(supportedActions, dropAction) == Qt::MoveAction) {
            // QAbstractItemView::startDrag calls d->clearOrRemove() here, so
            // this is a copy of QAbstractItemModelPrivate::clearOrRemove();
            const QItemSelection selection = selectionModel()->selection();
            QList<QItemSelectionRange>::const_iterator it = selection.constBegin();

            if (!dragDropOverwriteMode()) {
                for (; it != selection.constEnd(); ++it) {
                    QModelIndex parent = it->parent();
                    if (it->left() != 0)
                        continue;
                    if (it->right() != (model()->columnCount(parent) - 1))
                        continue;
                    int count = it->bottom() - it->top() + 1;
                    model()->removeRows(it->top(), count, parent);
                }
            } else {
                // we can't remove the rows so reset the items (i.e. the view is like a table)
                QModelIndexList list = selection.indexes();
                for (int i = 0; i < list.size(); ++i) {
                    QModelIndex index = list.at(i);
                    QMap<int, QVariant> roles = model()->itemData(index);
                    for (QMap<int, QVariant>::Iterator it = roles.begin(); it != roles.end(); ++it)
                        it.value() = QVariant();
                    model()->setItemData(index, roles);
                }
            }
        }
    }
}
开发者ID:RonnyPfannschmidt,项目名称:trojita,代码行数:95,代码来源:MsgListView.cpp


示例9: QDialog

//-------------------------------------------------------------------------
SetupDialog::SetupDialog(MainWindow *parent) 
 : QDialog(parent), mMainWindow(parent)
{
	setupUi(this);

	QObject::connect (fDefaultButton, SIGNAL(clicked()), this, SLOT(reset()));
	QObject::connect (fSysDistBox, SIGNAL(valueChanged(int)), this, SLOT(setup()));
	QObject::connect (fMaxDistBox, SIGNAL(valueChanged(int)), this, SLOT(setup()));
	QObject::connect (fSpringBox, SIGNAL(valueChanged(int)), this, SLOT(setup()));
	QObject::connect (fForceBox, SIGNAL(valueChanged(int)), this, SLOT(setup()));
	QObject::connect (fSysDistrMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(setup()));
	QObject::connect (fOPFcheckBox, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fNSpacingcheckBox, SIGNAL(clicked()), this, SLOT(setup()));
    QObject::connect (fResizePage2Music, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fColorButton, SIGNAL(clicked()) , this, SLOT(changeColor()));
	
	QObject::connect (fMapping, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fRawMapping, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fBoundingBoxes, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fPageBB, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fSystemBB, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fSystemSliceBB, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fStaffBB, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fMeasureBB, SIGNAL(clicked()), this, SLOT(setup()));
	QObject::connect (fEventBB, SIGNAL(clicked()), this, SLOT(setup()));

	QObject::connect (fVoiceNumEdit, SIGNAL(valueChanged(int)), this, SLOT(voiceStaffSetup(int)));
	QObject::connect (fStaffNumEdit, SIGNAL(valueChanged(int)), this, SLOT(voiceStaffSetup(int)));
	QObject::connect (fShowAllStaffsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(voiceStaffSetup(int)));
	QObject::connect (fShowAllVoicesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(voiceStaffSetup(int)));

	mSavedSettings = mMainWindow->getEngineSettings();
	mSavedBBMap = mMainWindow->getBBMap();
	mSavedShowMapping = mMainWindow->getShowMapping();
	mSavedRawMapping = mMainWindow->getRawMapping();
	mSavedShowBoxes = mMainWindow->getShowBoxes();
	mSavedVoiceNum = mMainWindow->getVoiceNum();
	mSavedStaffNum = mMainWindow->getStaffNum();
	scoreColorChanged( mMainWindow->getScoreColor() );
	set (mSavedSettings, mSavedBBMap, mSavedShowMapping, mSavedRawMapping, mSavedShowBoxes, mSavedVoiceNum, mSavedStaffNum);

	mFontColorMap[ GuidoHighlighter::VOICE_SEPARATOR_ELT ]	= fVoiceSeparatorColorButton;
	mFontColorMap[ GuidoHighlighter::SCORE_SEPARATOR_ELT ]	= fScoreSeparatorColorButton;
	mFontColorMap[ GuidoHighlighter::DURATION_ELT ]			= fDurationsColorButton;
	mFontColorMap[ GuidoHighlighter::NOTE_ELT ]				= fNotesColorButton;
	mFontColorMap[ GuidoHighlighter::TAG_PARAM_ELT ]		= fTagsParametersColorButton;
	mFontColorMap[ GuidoHighlighter::TAG_ELT ]				= fTagsColorButton;
	mFontColorMap[ GuidoHighlighter::COMMENT_ELT ]			= fCommentsColorButton;
						
	mFontWeightMap[ GuidoHighlighter::VOICE_SEPARATOR_ELT ]	= fVoiceSeparatorWeight;
	mFontWeightMap[ GuidoHighlighter::SCORE_SEPARATOR_ELT ]	= fScoreSeparatorWeight;
	mFontWeightMap[ GuidoHighlighter::DURATION_ELT ]		= fDurationsWeight;
	mFontWeightMap[ GuidoHighlighter::NOTE_ELT ]			= fNotesWeight;
	mFontWeightMap[ GuidoHighlighter::TAG_PARAM_ELT ]		= fTagsParametersWeight;
	mFontWeightMap[ GuidoHighlighter::TAG_ELT ]				= fTagsWeight;
	mFontWeightMap[ GuidoHighlighter::COMMENT_ELT ]			= fCommentsWeight;

	fTabWidget->setCurrentIndex(0);

	for ( int i = 0 ; i < GuidoHighlighter::SIZE ; i++ )
	{
		// Set widgets properties with syntax-element id
		mFontColorMap[ i ]->setProperty( SYNTAX_ELT_ID , i );
		mFontWeightMap[ i ]->setProperty( SYNTAX_ELT_ID , i );
		
		// Set the color of the font-color button
		QColor c = mMainWindow->getHighlighter()->color( i );
		QPixmap pixmap(30 , 30);
		pixmap.fill( c );
		mFontColorMap[ i ]->setIcon( QIcon(pixmap) );
		mFontColorMap[ i ]->setProperty( BUTTON_COLOR , c );
				
		// Adds font-weight items in the combobox
		for ( int w = 0 ; w <= QFont::Black ; w++ )
		{
			QString weightString = weightToString( w );
			if ( weightString.size() )
				mFontWeightMap[i]->addItem( weightString , w );
		}
		// Set the current combobox item
		QFont::Weight weight = (QFont::Weight)mMainWindow->getHighlighter()->weight( i );
		mFontWeightMap[i]->setCurrentIndex( mFontWeightMap[i]->findData( weight ) );
		
		// Connect the font widgets to their methods
		connect( mFontColorMap[i] , SIGNAL(clicked()) , this , SLOT(fontColorButtonClicked()) );
		connect( mFontWeightMap[i] , SIGNAL(currentIndexChanged(int)) , this , SLOT(fontWeightChanged(int)) );

		mSavedColors[i] = c;
		mSavedWeights[i]= int(weight);
	}

	if (!mColorDialog) {
		mColorDialog = new QColorDialog( this );
		mColorDialog->setWindowTitle("Choose score color");
		mColorDialog->setOption (QColorDialog::NoButtons);
	}
	
	QSettings settings;
    QPoint pos = settings.value(SETUP_DIALOG_POS_SETTING, QPoint(300, 300)).toPoint();
//.........这里部分代码省略.........
开发者ID:iloveican,项目名称:AscoGraph,代码行数:101,代码来源:SetupDialog.cpp


示例10: tar


//.........这里部分代码省略.........
                if (pix)
                    barrow.loadFromData(pix->data());
            }
            else if (key == "ForwardArrow") {
                const KArchiveEntry* e = subdir->entry(value);
                const KArchiveFile* pix = static_cast<const KArchiveFile*>(e);
                if (pix)
                    farrow.loadFromData(pix->data());
            }
            else if (key == "BackArrowX") {
                xba = value.toInt();
            }
            else if (key == "BackArrowY") {
                yba = value.toInt();
            }
            else if (key == "ForwardArrowX") {
                xfa = value.toInt();
            }
            else if (key == "ForwardArrowY") {
                yfa = value.toInt();
            }
        }
    }
    while (!line.isNull());

    int fontHeight = QFontMetrics(font).height();
    int pinyinw = QFontMetrics(font).width("ABC pinyin");
    int zhongwenw = QFontMetrics(font).width("1candidate");

    /// save target size
    int targetHeight = height;
    int targetWidth = width;

    height = mt + ych + mb;
    width = qMax(ml + pinyinw + mr, ml + zhongwenw + mr);
    width = qMax(width, targetWidth);
    width = qMax(width, skin.width());

    yen = mt + yen - fontHeight;
    ych = mt + ych - fontHeight;

    QPixmap pixmap(width, height);
    pixmap.fill(Qt::transparent);

    QPainter p(&pixmap);

    /// corners lt, lb, rt, rb
    p.drawPixmap(0, 0, skin,
                 0, 0, ml, mt);
    p.drawPixmap(0, height - mb, skin,
                 0, skin.height() - mb, ml, mb);
    p.drawPixmap(width - mr, 0, skin,
                 skin.width() - mr, 0, mr, mt);
    p.drawPixmap(width - mr, height - mb, skin,
                 skin.width() - mr, skin.height() - mb, mr, mb);

    /// left right
    p.drawPixmap(0, mt, ml, height - mt - mb, skin,
                 0, mt, ml, skin.height() - mt - mb);
    p.drawPixmap(width - mr, mt, mr, height - mt - mb, skin,
                 skin.width() - mr, mt, mr, skin.height() - mt - mb);

    /// top bottom
    p.drawPixmap(ml, 0, width - ml - mr, mt, skin,
                 ml, 0, skin.width() - ml - mr, mt);
    p.drawPixmap(ml, height - mb, width - ml - mr, mb, skin,
                 ml, skin.height() - mb, skin.width() - ml - mr, mb);

    /// middle
    p.drawPixmap(ml, mt, width - ml - mr, height - mt - mb, skin,
                 ml, mt, skin.width() - ml - mr, skin.height() - mt - mb);

    /// draw arrows
    p.drawPixmap(width - xba, yba, barrow);
    p.drawPixmap(width - xfa, yfa, farrow);

    /// draw preedit / aux text
    p.setFont(font);
    p.setPen(color_en);
    p.drawText(ml, yen, pinyinw, fontHeight, Qt::AlignCenter, "ABC pinyin");
    p.drawLine(ml + pinyinw, yen, ml + pinyinw, yen + fontHeight);

    /// draw lookup table
    p.setPen(color_label);
    int labelw = p.fontMetrics().width("1");
    p.drawText(ml, ych, labelw, fontHeight, Qt::AlignCenter, "1");
    p.setPen(color_ch_1st);
    int candidatew = p.fontMetrics().width("candidate");
    p.drawText(ml + labelw, ych, candidatew, fontHeight, Qt::AlignCenter, "candidate");

    p.end();

    if (targetWidth < width || targetHeight < height) {
        pixmap = pixmap.scaled(targetWidth, targetHeight, Qt::KeepAspectRatio);
    }

    img = pixmap.toImage();

    return true;
}
开发者ID:ahyangyi,项目名称:kimtoy,代码行数:101,代码来源:fskincreator.cpp


示例11: pixmap

/*!
  Draw a color bar into a rectangle

  \param painter Painter
  \param colorMap Color map
  \param interval Value range
  \param scaleMap Scale map
  \param orientation Orientation
  \param rect Traget rectangle
*/
void QwtPainter::drawColorBar( QPainter *painter,
        const QwtColorMap &colorMap, const QwtInterval &interval,
        const QwtScaleMap &scaleMap, Qt::Orientation orientation,
        const QRectF &rect )
{
    QVector<QRgb> colorTable;
    if ( colorMap.format() == QwtColorMap::Indexed )
        colorTable = colorMap.colorTable( interval );

    QColor c;

    const QRect devRect = rect.toAlignedRect();

    /*
      We paint to a pixmap first to have something scalable for printing
      ( f.e. in a Pdf document )
     */

    QPixmap pixmap( devRect.size() );
    QPainter pmPainter( &pixmap );
    pmPainter.translate( -devRect.x(), -devRect.y() );

    if ( orientation == Qt::Horizontal )
    {
        QwtScaleMap sMap = scaleMap;
        sMap.setPaintInterval( rect.left(), rect.right() );

        for ( int x = devRect.left(); x <= devRect.right(); x++ )
        {
            const double value = sMap.invTransform( x );

            if ( colorMap.format() == QwtColorMap::RGB )
                c.setRgba( colorMap.rgb( interval, value ) );
            else
                c = colorTable[colorMap.colorIndex( interval, value )];

            pmPainter.setPen( c );
            pmPainter.drawLine( x, devRect.top(), x, devRect.bottom() );
        }
    }
    else // Vertical
    {
        QwtScaleMap sMap = scaleMap;
        sMap.setPaintInterval( rect.bottom(), rect.top() );

        for ( int y = devRect.top(); y <= devRect.bottom(); y++ )
        {
            const double value = sMap.invTransform( y );

            if ( colorMap.format() == QwtColorMap::RGB )
                c.setRgb( colorMap.rgb( interval, value ) );
            else
                c = colorTable[colorMap.colorIndex( interval, value )];

            pmPainter.setPen( c );
            pmPainter.drawLine( devRect.left(), y, devRect.right(), y );
        }
    }
    pmPainter.end();

    drawPixmap( painter, rect, pixmap );
}
开发者ID:FabianFrancoRoldan,项目名称:OpenPilot,代码行数:72,代码来源:qwt_painter.cpp


示例12: QString

void tst_QStandardItem::getSetData()
{
    QStandardItem item;
    for (int x = 0; x < 2; ++x) {
        for (int i = 1; i <= 2; ++i) {
            QString text = QString("text %0").arg(i);
            item.setText(text);
            QCOMPARE(item.text(), text);
            
            QPixmap pixmap(32, 32);
            pixmap.fill((i == 1) ? Qt::red : Qt::green);
            QIcon icon(pixmap);
            item.setIcon(icon);
            QCOMPARE(item.icon(), icon);
            
            QString toolTip = QString("toolTip %0").arg(i);
            item.setToolTip(toolTip);
            QCOMPARE(item.toolTip(), toolTip);
            
            QString statusTip = QString("statusTip %0").arg(i);
            item.setStatusTip(statusTip);
            QCOMPARE(item.statusTip(), statusTip);
        
            QString whatsThis = QString("whatsThis %0").arg(i);
            item.setWhatsThis(whatsThis);
            QCOMPARE(item.whatsThis(), whatsThis);
            
            QSize sizeHint(64*i, 48*i);
            item.setSizeHint(sizeHint);
            QCOMPARE(item.sizeHint(), sizeHint);
            
            QFont font;
            item.setFont(font);
            QCOMPARE(item.font(), font);
        
            Qt::Alignment textAlignment((i == 1)
                                        ? Qt::AlignLeft|Qt::AlignVCenter
                                        : Qt::AlignRight);
            item.setTextAlignment(textAlignment);
            QCOMPARE(item.textAlignment(), textAlignment);
            
            QColor backgroundColor((i == 1) ? Qt::blue : Qt::yellow);
            item.setBackground(backgroundColor);
            QCOMPARE(item.background().color(), backgroundColor);
            
            QColor textColor((i == i) ? Qt::green : Qt::cyan);
            item.setForeground(textColor);
            QCOMPARE(item.foreground().color(), textColor);
            
            Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked);
            item.setCheckState(checkState);
            QCOMPARE(item.checkState(), checkState);
            
            QString accessibleText = QString("accessibleText %0").arg(i);
            item.setAccessibleText(accessibleText);
            QCOMPARE(item.accessibleText(), accessibleText);
            
            QString accessibleDescription = QString("accessibleDescription %0").arg(i);
            item.setAccessibleDescription(accessibleDescription);
            QCOMPARE(item.accessibleDescription(), accessibleDescription);
            
            QCOMPARE(item.text(), text);
            QCOMPARE(item.icon(), icon);
            QCOMPARE(item.toolTip(), toolTip);
            QCOMPARE(item.statusTip(), statusTip);
            QCOMPARE(item.whatsThis(), whatsThis);
            QCOMPARE(item.sizeHint(), sizeHint);
            QCOMPARE(item.font(), font);
            QCOMPARE(item.textAlignment(), textAlignment);
            QCOMPARE(item.background().color(), backgroundColor);
            QCOMPARE(item.foreground().color(), textColor);
            QCOMPARE(item.checkState(), checkState);
            QCOMPARE(item.accessibleText(), accessibleText);
            QCOMPARE(item.accessibleDescription(), accessibleDescription);
            
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::DisplayRole)), text);
            QCOMPARE(qvariant_cast<QIcon>(item.data(Qt::DecorationRole)), icon);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::ToolTipRole)), toolTip);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::StatusTipRole)), statusTip);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::WhatsThisRole)), whatsThis);
            QCOMPARE(qvariant_cast<QSize>(item.data(Qt::SizeHintRole)), sizeHint);
            QCOMPARE(qvariant_cast<QFont>(item.data(Qt::FontRole)), font);
            QCOMPARE(qvariant_cast<int>(item.data(Qt::TextAlignmentRole)), int(textAlignment));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundColorRole)), QBrush(backgroundColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)), QBrush(backgroundColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::TextColorRole)), QBrush(textColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::ForegroundRole)), QBrush(textColor));
            QCOMPARE(qvariant_cast<int>(item.data(Qt::CheckStateRole)), int(checkState));
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleTextRole)), accessibleText);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleDescriptionRole)), accessibleDescription);

            item.setBackground(pixmap);
            QCOMPARE(item.background().texture(), pixmap);
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)).texture(), pixmap);
        }
        item.setData(QVariant(), Qt::DisplayRole);
        item.setData(QVariant(), Qt::DecorationRole);
        item.setData(QVariant(), Qt::ToolTipRole);
        item.setData(QVariant(), Qt::StatusTipRole);
        item.setData(QVariant(), Qt::WhatsThisRole);
//.........这里部分代码省略.........
开发者ID:maxxant,项目名称:qt,代码行数:101,代码来源:tst_qstandarditem.cpp


示例13: plot


//.........这里部分代码省略.........
        if (!sameYUnits) {
          if (!label_info.units.isEmpty()) {
            y_label = i18n("%1 \\[%2\\]").arg(y_label).arg(label_info.units);
          }
        }
        if (!y_label.isEmpty()) {
          LabelInfo xlabel_info = relation->xLabelInfo();
          if (!sameX) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else if (xlabel_info.quantity.isEmpty()) {
            label = y_label;
          } else if (xlabel_info.quantity != xlabel_info.name) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else {
            label = y_label;
          }
        } else {
          label = relation->descriptiveName();
        }
      }
      int i_dup = names.indexOf(label);
      if (i_dup<0) {
        names.append(label);
      } else {
        RelationPtr dup_relation = legendItems.at(i_dup);
        if (!dup_relation->yLabelInfo().file.isEmpty()) {
          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().file + ')');
        }
        if (!relation->yLabelInfo().file.isEmpty()) {
          names.append(label + " (" + relation->yLabelInfo().file + ')');
        }
      }
    }
  }

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    DrawnLegendItem item;
    item.pixmap = QPixmap(LEGENDITEMMAXWIDTH, LEGENDITEMMAXHEIGHT);
    item.size = paintRelation(names.at(i), relation, &item.pixmap, font);

    if (_verticalDisplay) {
      legendSize.setWidth(qMax(legendSize.width(), item.size.width()));
      legendSize.setHeight(legendSize.height() + item.size.height());
    } else {
      legendSize.setHeight(qMax(legendSize.height(), item.size.height()));
      legendSize.setWidth(legendSize.width() + item.size.width());
    }

    legendPixmaps.append(item);
  }

  int x = rect().left();
  int y = rect().top();

  painter->save();

  if (!_title.isEmpty()) {
    // Paint the title
    Label::Parsed *parsed = Label::parse(_title);

    if (parsed) {
      painter->save();

      QPixmap pixmap(400, 100);
      pixmap.fill(Qt::transparent);
      QPainter pixmapPainter(&pixmap);

      Label::RenderContext rc(font, &pixmapPainter);
      QFontMetrics fm(font);
      rc.y = fm.ascent();
      Label::renderLabel(rc, parsed->chunk, false);

      int startPoint = qMax(0, (legendSize.width() / 2) - (rc.x / 2));
      int paddingValue = fm.height() / 4;
    
      setViewRect(viewRect().x(), viewRect().y(), qMax(rc.x, legendSize.width()), rc.y + legendSize.height() + paddingValue * 3);
      painter->drawRect(rect());

      painter->drawPixmap(QPoint(x + startPoint, y + paddingValue), pixmap, QRect(0, 0, rc.x, fm.height()));
      painter->restore();
      y += fm.height() + (paddingValue *2);
      delete parsed;
      parsed = 0;
    }
  } else {
    // No Title
    setViewRect(viewRect().x(), viewRect().y(), legendSize.width(), legendSize.height());
    painter->drawRect(rect());
  }


  foreach(const DrawnLegendItem &item, legendPixmaps) {
    painter->drawPixmap(QPoint(x, y), item.pixmap, QRect(0, 0, item.size.width(), item.size.height()));
    if (_verticalDisplay) {
      y += item.size.height();
    } else {
      x += item.size.width();
    }
  }
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:101,代码来源:legenditem.cpp


示例14: connect

    _newAct->setEnabled(false);
    connect(_newAct, SIGNAL(triggered()), this, SLOT(sNew()));
    addAction(_newAct);

    connect(this, SIGNAL(valid(bool)), _infoAct, SLOT(setEnabled(bool)));

    _menuLabel = new QLabel(this);
    // Menu set up

    _menu = 0;
    _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png"));
    _menuLabel->installEventFilter(this);

    int height = minimumSizeHint().height();
    QString sheet = QLatin1String("QLineEdit{ padding-right: ");
    sheet += QString::number(_menuLabel->pixmap()->width() + 6);
    sheet += QLatin1String(";}");
    setStyleSheet(sheet);
    // Little hack. Somehow style sheet makes widget short. Put back height.
    setMinimumHeight(height);

    // Set default menu with standard actions
    QMenu* menu = new QMenu;
    menu->addAction(_listAct);
    menu->addAction(_searchAct);
    menu->addSeparator();
    menu->addAction(_infoAct);
    setMenu(menu);

    connect(this, SIGNAL(valid(bool)), this, SLOT(sUpdateMenu()));
    connect(menu, SIGNAL(aboutToShow()), this, SLOT(sUpdateMenu()));
开发者ID:aniuska,项目名称:qt-client,代码行数:31,代码来源:virtualCluster.cpp


示例15: pos

void MyShip::cnstrct_shldpxmp() {
	shpshld->setPos(pos().x() + (pixmap().width() / 2) - (shpshld->pixmap().width() / 2),
	                pos().y() + (pixmap().height() / 2) - (shpshld->pixmap().height() / 2));
}
开发者ID:kahrabian,项目名称:Shooter-AP93UT,代码行数:4,代码来源:MyShip.cpp


示例16: QDialog

NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QDialog(parent),
	m_notification(notification),
	m_closeLabel(nullptr),
	m_closeTimer(0)
{
	QFrame *notificationFrame(new QFrame(this));
	notificationFrame->setObjectName(QLatin1String("notificationFrame"));
	notificationFrame->setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}"));
	notificationFrame->setCursor(QCursor(Qt::PointingHandCursor));
	notificationFrame->installEventFilter(this);

	QBoxLayout *mainLayout(new QBoxLayout(QBoxLayout::LeftToRight));
	mainLayout->setContentsMargins(0, 0, 0, 0);
	mainLayout->setSpacing(0);
	mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
	mainLayout->addWidget(notificationFrame);

	QLabel *iconLabel(new QLabel(this));
	iconLabel->setPixmap(ThemesManager::createIcon(QLatin1String("otter-browser-32")).pixmap(32, 32));
	iconLabel->setStyleSheet(QLatin1String("padding:5px;"));

	QLabel *messageLabel(new QLabel(this));
	messageLabel->setText(m_notification->getMessage());
	messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;"));
	messageLabel->setWordWrap(true);

	QStyleOption option;
	option.rect = QRect(0, 0, 16, 16);

	QPixmap pixmap(16, 16);
	pixmap.fill(Qt::transparent);

	QPainter painter(&pixmap);

	style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this);

	m_closeLabel = new QLabel(notificationFrame);
	m_closeLabel->setToolTip(tr("Close"));
	m_closeLabel->setPixmap(pixmap);
	m_closeLabel->setAlignment(Qt::AlignTop);
	m_closeLabel->setMargin(5);
	m_closeLabel->installEventFilter(this);

	QBoxLayout *notificationLayout(new QBoxLayout(QBoxLayout::LeftToRight));
	notificationLayout->setContentsMargins(0, 0, 0, 0);
	notificationLayout->setSpacing(0);
	notificationLayout->setSizeConstraint(QLayout::SetMinimumSize);
	notificationLayout->addWidget(iconLabel);
	notificationLayout->addWidget(messageLabel);
	notificationLayout->addWidget(m_closeLabel);

	notificationFrame->setLayout(notificationLayout);

	setLayout(mainLayout);
	setFixedWidth(400);
	setMinimumHeight(50);
	setMaximumHeight(150);
	setWindowOpacity(0);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint);
	setFocusPolicy(Qt::NoFocus);
	setAttribute(Qt::WA_DeleteOnClose, true);
	setAttribute(Qt::WA_ShowWithoutActivating, true);
	setAttribute(Qt::WA_TranslucentBackground, true);
	adjustSize();

	m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1());
	m_animation->setDuration(500);
	m_animation->setStartValue(0.0);
	m_animation->setEndValue(1.0);
	m_animation->start();

	const int visibilityDuration(SettingsManager::getOption(SettingsManager::Interface_NotificationVisibilityDurationOption).toInt());

	if (visibilityDuration > 0)
	{
		m_closeTimer = startTimer(visibilityDuration * 1000);
	}
}
开发者ID:haydara,项目名称:otter,代码行数:78,代码来源:NotificationDialog.cpp


示例17: getSearchResult

void SearchResultItemDelegate::paint(QPainter *painter,
                                     const QStyleOptionViewItem &option,
                                     const QModelIndex &index) const {
    const SearchResultListModel *model = static_cast<const SearchResultListModel*>(index.model());
    QBrush backBrush;
    bool selected = false;
    FileSearchResult file = getSearchResult(index);

    if (option.state & (QStyle::State_HasFocus | QStyle::State_Selected)) {
        backBrush = QColor(kFileItemBackgroundColorHighlighted);
        selected = true;
    } else {
        backBrush = QColor(kFileItemBackgroundColor);
    }

    //
    // draw item's background
    //
    painter->save();
    painter->fillRect(option.rect, backBrush);
    painter->restore();

    QIcon icon = model->data(index, Qt::DecorationRole).value<QIcon>();
    // get the device pixel radio from current painter device
    int scale_factor = 1;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    scale_factor = painter->device()->devicePixelRatio();
#endif // QT5
    QPixmap pixmap(icon.pixmap(QSize(kFileIconWidth, kFileIconHeight) * scale_factor));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    if (pixmap.size() != QSize(kFileIconWidth, kFileIconHeight))
        pixmap.setDevicePixelRatio(scale_factor);
#endif // QT5

    //
    // paint file icon
    //
    QPoint file_icon_pos(kMarginLeft + kPadding, kMarginTop + kPadding);
    file_icon_pos += option.rect.topLeft();
    painter->save();
    painter->drawPixmap(file_icon_pos, pixmap);
    painter-&g 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pixval32f函数代码示例发布时间:2022-05-30
下一篇:
C++ pixman_image_unref函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap