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


C++ MyRect类代码示例

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


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

示例1: on_editHLCol_clicked

void MainWindow::on_editHLCol_clicked()
{
    MyRect * r = MyRect::m_selectedRect;
    QColor col = QColorDialog::getColor(r->getColor(), this,
                                        QString("Choose Text Background Color"),
                                        QColorDialog::ShowAlphaChannel);
    if(col.isValid())
        r->setColor(col);
}
开发者ID:spbond,项目名称:language-game,代码行数:9,代码来源:mainwindow.cpp

示例2: on_editText_clicked

void MainWindow::on_editText_clicked()
{
    MyRect * r = MyRect::m_selectedRect;
    bool ok;
    QString text = QInputDialog::getText(this, tr("Enter Text"),
                                         tr("Text:"), QLineEdit::Normal,
                                         r->getText(), &ok);
    if(ok && !text.isEmpty())
        r->setText(text);
}
开发者ID:spbond,项目名称:language-game,代码行数:10,代码来源:mainwindow.cpp

示例3: on_goToScene_activated

void MainWindow::on_goToScene_activated(const QString &arg1)
{
    MyRect * r = MyRect::m_selectedRect;
    if(!ui->goToScene->currentIndex())
    {
        r->setId(0);
        ui->badgeWidg->setHidden(true);
        return;
    }
    r->setId(m_scenes->id(arg1));
    ui->badgeWidg->setHidden(false);
}
开发者ID:spbond,项目名称:language-game,代码行数:12,代码来源:mainwindow.cpp

示例4: on_sndPitch_valueChanged

void MainWindow::on_sndPitch_valueChanged(int value)
{
    ScreenQGV::EditorType edType = ui->graphicsView->editorType();

    if(edType == ScreenQGV::MAP || edType == ScreenQGV::SCENE)
    {
        MyRect * r = MyRect::m_selectedRect;
        r->setPitch(value);
    }
    else
    {
        ui->graphicsView->setRewardSoundPitch(value);
    }
}
开发者ID:spbond,项目名称:language-game,代码行数:14,代码来源:mainwindow.cpp

示例5: SetViewRgn

void DjvuPic::SetViewRgn(MyRect rgn)
{	
	CSize size=rgn.Size(); CPoint topleft=rgn.TopLeft();
	
	if(size.cx>Buffer->w) size.cx=Buffer->w;
    if(size.cy>Buffer->h) size.cy=Buffer->h;
	
	if(rgn.left<0) topleft.x=0;
	if(rgn.right>Buffer->w) topleft.x=Buffer->w-size.cx;

	if(rgn.top<0) topleft.y=0;	
	if(rgn.bottom>Buffer->h) topleft.y=Buffer->h-size.cy;

    ViewRgn=CRect(topleft,size);
	return;
}
开发者ID:mar80nik,项目名称:testWMF,代码行数:16,代码来源:DjvuPic.cpp

示例6: QGraphicsScene

Game::Game(QWidget* parent){

    QGraphicsScene * scene = new QGraphicsScene();
    scene->setSceneRect(0,0,800,600);
    setBackgroundBrush(QBrush(QImage(":/images/bg4.jpg")));

    setWindowTitle("Taiko~");
    setScene(scene);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFixedSize(800,600);


    //create the player
    MyRect * rect = new MyRect();
//    setPixmap(QPixmap(":/images/rect.jpg"));
//    rect -> setRect (0,0,10,10);
//    rect->setPos(width()/2,height()-rect->rect().height());
    rect->setPos(230,235);


    //make the player focusable
    rect->setFlag(QGraphicsItem::ItemIsFocusable);
    rect->setFocus();
    // add the rect to the scene
    scene->addItem(rect);

    //create the score
    score = new Score();
    score->setPos(40,210);
    scene->addItem(score);
    
    //create the time
    time = new Time();
    time->setPos(42,243);
    scene->addItem(time);
    //time->countdown ->start();

    //spawn enemies
    QTimer  * timer = new QTimer();
    QObject::connect(timer, SIGNAL(timeout()),rect,SLOT(spawn()));
    timer->start(1000);

}
开发者ID:F74046080,项目名称:pd2-Taiko,代码行数:44,代码来源:game.cpp

示例7: RectInVect

//Returns true is the vector "v" contains a rect that is similar to "r".
//If s0, "r" is replaced by that rect.
bool History::RectInVect(MyRect &r, const vector<MyRect> &v)
{
	vector<MyRect>::const_iterator iter;
	for(iter=v.begin(); iter!=v.end(); ++iter)
	{
		if(r.similar(*iter)) {r = *iter; return true;}
	}

	return false;
}
开发者ID:miguelao,项目名称:gst_plugins_tsunami,代码行数:12,代码来源:history.cpp

示例8: on_delSnd_clicked

void MainWindow::on_delSnd_clicked()
{
    ScreenQGV::EditorType edType = ui->graphicsView->editorType();

    if(edType == ScreenQGV::MAP || edType == ScreenQGV::SCENE)
    {
        MyRect * r = MyRect::m_selectedRect;
        r->setHasSound(false);
        m_fileManager.deleteFile(r->sndFilepath());
    }
    else
    {
        ui->graphicsView->setRewardSoundFile(L"None");
        ui->graphicsView->setRewardSoundVolume(50);
        ui->graphicsView->setRewardSoundPitch(1);
    }
    ui->addSnd->setHidden(false);
    ui->delSnd->setHidden(true);
    ui->sndVolWidg->setHidden(true);
    ui->sndPitchWidg->setHidden(true);
}
开发者ID:spbond,项目名称:language-game,代码行数:21,代码来源:mainwindow.cpp

示例9: tr

void MainWindow::on_addSnd_clicked()
{
    ScreenQGV::EditorType edType = ui->graphicsView->editorType();

    QString selfilter = tr("All files (*.wav)");
    QString filename = QFileDialog::getOpenFileName(
            this,
            QString("Select Sound"),
            QString(""),
            tr("All files (*.wav)" ),
            &selfilter
    );
    if(filename.isEmpty())
        return;
    QString newFile = m_fileManager.copyFile(filename, FileManager::OTHERSND);

    if(edType == ScreenQGV::MAP || edType == ScreenQGV::SCENE)
    {
        MyRect * r = MyRect::m_selectedRect;
        r->setSndFilepath(newFile);
        r->setVol(50);
        r->setPitch(1);
    }
    else
    {
        cout << "sound file is " << filename.toStdString() << endl;

        ui->graphicsView->setRewardSoundFile(newFile.toStdWString());
        ui->graphicsView->setRewardSoundVolume(ui->sndVol->value());
        ui->graphicsView->setRewardSoundPitch(1);
        QString qS = QString::fromStdWString(ui->graphicsView->getRewardSoundFile());
        cout << "screen's sound file is " << qS.toStdString() << endl;
    }
    ui->addSnd->setHidden(true);
    ui->delSnd->setHidden(false);
    ui->sndVolWidg->setHidden(false);
}
开发者ID:spbond,项目名称:language-game,代码行数:37,代码来源:mainwindow.cpp

示例10: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Create a scene
    QGraphicsScene * mygamescene = new QGraphicsScene();
    MyRect * player = new MyRect();
    player->setRect(0,0,50,50);
    mygamescene->addItem(player);
    // Make rect respond to events
    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();
    QGraphicsView * myview = new QGraphicsView(mygamescene);
    myview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    myview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    myview->show();
    myview->setFixedSize(800,600);
    mygamescene->setSceneRect(0,0,800,600);
    player->setPos((myview->width()-player->rect().width())/2,myview->height()-player->rect().height());
    return a.exec();
}
开发者ID:virtualjames,项目名称:splash2d,代码行数:21,代码来源:main.cpp

示例11: Draw

void Draw()
{
	// 화면 지우기
	system("cls");

	for (int i = 0; i < npcs.size(); i = i + 1)
	{
		// npcs[i] == MyRect
		npcs[i].Draw();
	}
	/*
	npc1.Draw();
	npc2.Draw();
	npc3.Draw();
	npc4.Draw();
	npc5.Draw();
	npc6.Draw();
	npc7.Draw();
	npc8.Draw();
	npc9.Draw();
	npc10.Draw();
	*/
	myRect.Draw();
}
开发者ID:nakta1617,项目名称:sbs20120806,代码行数:24,代码来源:Shapes.cpp

示例12: player

/*Tutorial:
QGraphicsScene: world, player (Inivisble ~concept)
QGraphicsItem(QGraphicsRectitem): goes into scene
QGraphicsView:
*/
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //Create a scene
    QGraphicsScene *scene  = new QGraphicsScene();

    //Create an item to put into the scene
    MyRect *rect = new MyRect();

    rect->setRect(0,0,100,100); //(x,y,width,height)

    //Add item to the Scene
    scene->addItem(rect);

    //Make Rect focusable
    rect->setFlag(QGraphicsItem::ItemIsFocusable); //Only one focused item at a time
                                                   //Allowing rect to be focusable
    rect->setFocus(); //Setting rect item to focus

    //Add a view
    QGraphicsView *view = new QGraphicsView(scene); //Initializing in constructor
    //view->setScene(scene); alternative

    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    view->show();

    view->setFixedSize(800,600);
    scene->setSceneRect(0,0,800,600);

    rect->setPos(view->width()/2,view->height() - rect->rect().height());

    //Spawn Enemies
    QTimer *timer = new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),rect,SLOT(spawn()));
    timer->start(2000);

    return a.exec();
}
开发者ID:Scieon,项目名称:Qt,代码行数:46,代码来源:main.cpp

示例13: if

void MainWindow::on_goToActivity_activated(const QString &arg1)
{
    MyRect * r = MyRect::m_selectedRect;

    if(!ui->goToActivity->currentIndex())
    {
        cout << "Setting MyRect with " << r->id() << " 0" << endl;
        r->setId(0);
        r->setGameType(GameType::NONE);
        ui->actPieceWidg->setHidden(true);
        r->setActPieceFilepath(QString("None"));
        if(!ui->graphicsView->actsAreInScene())
            ui->chooseRewardBadge->setEnabled(false);
        return;
    }
    QString actType = ui->goToActivity->currentText().section(QChar('-'), 0, 0);
    actType = actType.remove(QChar(' '));
    QString str = ui->goToActivity->currentText().section(QChar('-'), 1, 1);
    if(ui->graphicsView->rewardBadgeId())
        ui->actPieceWidg->setHidden(false);

    if(!r->id())
    {
        r->setActPieceFilepath(m_fileManager.errorImgFilepath());
        ui->actPieceImg->setPixmap(QPixmap(r->actPieceFilepath()).scaled(50, 50,
                                                                         Qt::KeepAspectRatioByExpanding,
                                                                         Qt::FastTransformation));
    }
    if(actType == QString("Pairing"))
    {
        r->setId(m_pairActs->id(str.remove(0, 1)));
        r->setGameType(GameType::PAIR);
    }
    else if(actType == QString("Matching"))
    {
        r->setId(m_matchActs->id(str.remove(0, 1)));
        r->setGameType(GameType::MATCHING);
        cout << "set matching" << endl;
    }
    if(r->id())
    {
        string actFileName = MyRect::m_selectedRect->actFileName().toStdString();
         Activity *act = new Activity(actFileName, NULL);
        act->load();
        ui->actPieceImg->setPixmap(QPixmap(QString::fromStdWString(act->m_badge_piece.m_image)).scaled(50, 50,
                                                                         Qt::KeepAspectRatioByExpanding,
                                                                         Qt::FastTransformation));
        r->setActPieceFilepath(QString::fromStdWString(act->m_badge_piece.m_image));
    }
    if(ui->graphicsView->actsAreInScene())
        ui->chooseRewardBadge->setEnabled(true);
}
开发者ID:spbond,项目名称:language-game,代码行数:52,代码来源:mainwindow.cpp

示例14: on_hovLineEdit_textEdited

void MainWindow::on_hovLineEdit_textEdited(const QString &arg1)
{
    MyRect * r = MyRect::m_selectedRect;
    r->setHoverText(arg1);
}
开发者ID:spbond,项目名称:language-game,代码行数:5,代码来源:mainwindow.cpp

示例15: QWidget

/* GameBored contstructor
 * @param QWidget is the parent widget
*/
GameBored::GameBored(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GameBored)
{
    ui->setupUi(this);

    // make scene
    QGraphicsScene * scene= new QGraphicsScene();
    scene->setSceneRect(0,0,800,600);
    scene->setBackgroundBrush(QBrush(QImage(":/pics/bg")));


    // make and add item to scene
    MyRect * player = new MyRect();
    scene->addItem(player);

    // focus item so that it can receive keyboard events
    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();


    // add scene to new view
    QGraphicsView * view = new QGraphicsView(scene);

    //turn off scrollbars
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);


    Board= new QWidget;
    //Board->setFixedSize(400,400);

    // add view to new layout
    // add layout to central widget
    QVBoxLayout * vlayout = new QVBoxLayout(Board);
    vlayout->addWidget(view);
    this->setLayout(vlayout);

    //
    this->show();
    view->setFixedSize(800,600);
    scene->setSceneRect(0,0,800,600);

    player->setPos(view->width()/2 -player->pixmap().width()/2, -28 /*view->height()- player->pixmap().height()*/);

    // constant creation of enemies
    QTimer* timer = new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(2400);

    QTimer* timer2 = new QTimer();
    QObject::connect(timer2,SIGNAL(timeout()),player,SLOT(spawn2()));
    timer2->start(5000);


    // play music
    mp3player = new QMediaPlayer();
    mp3player->setMedia(QUrl("qrc:/audio/starfox.mp3"));
    mp3player->play();

    // add score class to screen
    score = new Score();
    scene->addItem(score);
}
开发者ID:aslanmpour,项目名称:Repository,代码行数:67,代码来源:gamebored.cpp


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