コード例 #1
0
ファイル: bufferslider.cpp プロジェクト: Rainbox-dev/Dufrap
void BufferSlider::setNumFrames(int n)
{
    setUpdatesEnabled(false);

    int currentWidth = this->width();

    //vider
    while (frameLabels.count()>0)
    {
        bufferLayout->removeWidget(frameLabels[frameLabels.count()-1]);
        QLabel *l = frameLabels.takeLast();
        delete l;
    }

    if (n<=0) return;

    //remettre
    while (frameLabels.count()<n)
    {
        QLabel *newFrame = new QLabel(this);
        newFrame->resize(1,3);
        newFrame->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
        bufferLayout->addWidget(newFrame);
        frameLabels << newFrame;
    }

    this->resize(currentWidth,3);

    setUpdatesEnabled(true);
}
コード例 #2
0
ファイル: utility.cpp プロジェクト: JandunCN/AllInGithub
YGButton* Utility::button_ImageNText(const QSize &size, const QPoint &pos, const QString &bgImagePath,
                                     const QString &text, const QString &textColor, int fontPixelSize, bool fontBold,
                                     const QString &objName, QWidget *parent)
{
    YGButton *btn= new YGButton(YGButton::ButtonType_ImageBtn, parent);
    btn->addLanguageRes(QLocale::Chinese, bgImagePath);
    btn->addLanguageRes(QLocale::English, bgImagePath);
    if(!objName.isEmpty())
    {
        btn->setObjectName(objName);
    }
    btn->resize(size);
    btn->move(pos);

    QLabel *lbl = new QLabel(btn);
    lbl->resize(btn->size());
    if(fontBold)
    {
        lbl->setStyleSheet(QString("QLabel{background:transparent;  color:%1; font-size: %2px; font-weight:bold;}").arg(textColor).arg(fontPixelSize));
    }
    else
    {
        lbl->setStyleSheet(QString("QLabel{background:transparent;  color:%1; font-size: %2px;}").arg(textColor).arg(fontPixelSize));
    }
    lbl->setText(text);
    lbl->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);

    return btn;
}
コード例 #3
0
void NumberChoiceLive::chooseNumber(int number) {
	//numbers[number]->setText(QString(QChar(prizes[number])));
	QPixmap *prizeImage;
	
	switch(prizes[number]) {
		case 'B':
			if (isVisible()) QSound::play("media/sounds/PrizeBronze.wav");
			prizeImage = prizeBronze;
			break;
		case 'S':
			if (isVisible()) QSound::play("media/sounds/PrizeSilver.wav");
			prizeImage = prizeSilver;
			break;
		case 'G':
			if (isVisible()) QSound::play("media/sounds/PrizeGold.wav");
			prizeImage = prizeGold;
			break;
	}
	QPixmap smallerPrize = prizeImage->scaled(numbers[number]->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
	QLabel *medal = new QLabel(numbers[number]->parentWidget());
	medal->setAttribute(Qt::WA_DeleteOnClose);
	medal->setPixmap(smallerPrize);
	medal->resize(smallerPrize.size()); // Using . rather than -> with smallerPrize because smallerPrize isn't a pointer
	medal->move(numbers[number]->geometry().center() - medal->geometry().center());
	medal->show();
	connect(this, SIGNAL(resetAll(bool)), medal, SLOT(close()));
}
コード例 #4
0
ファイル: qswindow.cpp プロジェクト: scoreur/QS
//////////////////////////////////////////////////////////////////
/// @brief music slot:
///
/////////////////////////////////////////////////////////////////
void QSWindow::musicInit(){
    playButton = new QPushButton(ui->wavTab);
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    playButton->setText("play");
    playButton->move(0, wavView->height()+25);
    playTime = new QLabel(ui->wavTab);
    playTime->move(wavView->width()-160, wavView->height()+25);
    playTime->resize(160,20);
    playTime->setText("00:00.00/00:00.00");

    positionSlider = new QSlider(Qt::Horizontal,ui->wavTab);
    positionSlider->resize(wavView->width(),20);
    positionSlider->move(wavView->rect().bottomLeft());
    positionSlider->setRange(0, 0);

    wavView->horizontalScrollBar()->setSingleStep(5);

    QLabel *mouseTime = new QLabel(ui->wavTab);
    ((WavView*)wavView)->mouseTime = mouseTime;
    mouseTime->move(wavView->width()-360, wavView->height()+25);
    mouseTime->resize(100, 20);
    mouseTime->setText("00:00.000");

    recorder->recordButton->setParent(ui->wavTab);
    recorder->recordButton->move(100, wavView->height()+100);
    recorder->recordButton->setEnabled(true);


}
コード例 #5
0
ファイル: popup_param.cpp プロジェクト: devernay/ramen-1
QWidget *popup_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    QLabel *label = new QLabel( top);
    menu_ = new QComboBox( top);
    menu_->setFocusPolicy( Qt::NoFocus);

    for( int i = 0; i < menu_items_.size(); ++i)
    {
        if( menu_items_[i] == "--")
            menu_->insertSeparator( menu_->count());
        else
            menu_->addItem( menu_items_[i].c_str());
    }

    QSize s = menu_->sizeHint();

    label->move( 0, 0);
    label->resize( app().ui()->inspector().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());
    label->setToolTip( id().c_str());

    menu_->move( app().ui()->inspector().left_margin(), 0);
    menu_->resize( s.width(), s.height());
    menu_->setCurrentIndex( get_value<int>( *this));
    menu_->setEnabled( enabled());
    connect( menu_, SIGNAL( currentIndexChanged( int)), this, SLOT( item_picked( int)));

    top->setMinimumSize( app().ui()->inspector().width(), s.height());
    top->setMaximumSize( app().ui()->inspector().width(), s.height());
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
    return top;
}
コード例 #6
0
ファイル: largetable.cpp プロジェクト: sgielen/chatprototype
void LargeTable::scrollToHeight(int height) {
    auto rowsAndOffset = rowsAndOffsetForHeight(height);
    std::list<LargeTableModel::RowIndex> rows = rowsAndOffset.first;
    int offset = -rowsAndOffset.second;
    // The messages indicated by <rows> should be drawn from the top of the screen
    // Its top position should be <offst> pixels above the top of the screen
    // clear it
    QList<QWidget*> widgets = findChildren<QWidget*>();
    foreach(QWidget *widget, widgets) {
        delete widget;
    }
    for(LargeTableModel::RowIndex ri : rows) {
        unsigned int width = 0;
        LargeTableModel::Row &r = ltm->at(ri);
        for(unsigned int column = 0; column < r.size(); ++column) {
            QLabel *label = new QLabel(QString::fromStdString(r.at(column)), this);
            label->resize(columnWidths[column], heights[ri]);
            label->setAlignment(Qt::AlignTop);
            label->move(width, offset);
            label->show();
            label->setWordWrap(true);
            label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
            width += columnWidths[column];
        }
        offset += heights[ri];
    }
}
コード例 #7
0
ファイル: Fenetre.cpp プロジェクト: puchka/QCalendar_2
Fenetre::Fenetre()
    :QWidget()
{
    this->setFixedSize(450, 250);
    QLabel* fond = new QLabel(this);
    fond->resize(500, 500);
    fond->move(0, -30);
    fond->setPixmap(QPixmap("fond.png"));
    Table * m_case;
    m_case = new Table(this);
    m_case -> move(30, 70);

    Bouton *p_bouton;
    p_bouton = new Bouton("<", this);
    p_bouton->setGeometry(30, 40, 30, 20);

    Bouton *n_bouton;
    n_bouton = new Bouton(">", this);
    n_bouton->setGeometry(205, 40, 30, 20);

    Bouton *about;
    about = new Bouton("About Us", this);
    about->setGeometry(315, 40, 60, 20);

    Clock *clock;
    clock = new Clock(150, this);
    clock->move(270, 75);

    QObject::connect(p_bouton, SIGNAL(clicked()), m_case, SLOT(moisPrecedent()));
    QObject::connect(n_bouton, SIGNAL(clicked()), m_case, SLOT(moisSuivant()));

    QObject::connect(about, SIGNAL(clicked()), m_case, SLOT(aboutUs()));
}
コード例 #8
0
//
// Private Methods
//
void MainWindow::popupImage(const QString &fileName) const
{
    QPixmap image = QPixmap::fromImage(QImage(fileName));
    QLabel *morphemesLabel = new QLabel;
    morphemesLabel->setPixmap(image);
    morphemesLabel->resize(image.size());
    morphemesLabel->show();
}
コード例 #9
0
void NotificationDialog::getDataFromDatabase(){
    ui->tableWidget->setRowCount(0);
    bool disconnect = false;
    bool connected = true;
    if(!db.isOpen()){
        disconnect = true;
        connected = parent->connectToDatabase(&db, false, this);
    }
    if(connected){
        for(int i = 0; i < parent->cNotifications.size(); i++){
            QLabel * item = new QLabel;
            QStringList columnNames = parent->getColumnsNames("Customers");
            QVector<QStringList> retrievedData = parent->executeSelectCommand("Customers", columnNames, "ID=" + QString::number(parent->cNotifications[i].customer));
            if(!retrievedData.isEmpty()){
                if(!retrievedData[0].isEmpty()){
                    item->setText(retrievedData[columnNames.indexOf("Surname")][0] + " " + retrievedData[columnNames.indexOf("Name")][0] + " " + retrievedData[columnNames.indexOf("Patronomic")][0] + "\nТелефонный номер: (" + retrievedData[columnNames.indexOf("PhoneCode")][0] + ")" + retrievedData[columnNames.indexOf("PhoneNumber")][0] + "\nПО: " + parent->cNotifications[i].soft + "\nДата истечения лицензии: " + parent->cNotifications[i].date);
                    QFontMetrics fontMetrics = item->fontMetrics();
                    QSize textSize = fontMetrics.size(0, item->text());
                    int textWidth = textSize.width() + 30;
                    int textHeight = textSize.height() + 20;
                    item->setMinimumSize(textWidth, textHeight);
                    item->resize(textWidth, textHeight);
                    ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
                    ui->tableWidget->setCellWidget(ui->tableWidget->rowCount() - 1, 0, item);
                    ui->tableWidget->setRowHeight(ui->tableWidget->rowCount() - 1, textHeight);
                }
            }
        }
        for(int i = 0; i < parent->lNotifications.size(); i++){
            QLabel * item = new QLabel;
            item->setText("ПО: " + parent->lNotifications[i].soft + "\nОсталось лицензий: " + QString::number(parent->lNotifications[i].count));
            QFontMetrics fontMetrics = item->fontMetrics();
            QSize textSize = fontMetrics.size(0, item->text());
            int textWidth = textSize.width() + 30;
            int textHeight = textSize.height() + 20;
            item->setMinimumSize(textWidth, textHeight);
            item->resize(textWidth, textHeight);
            ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
            ui->tableWidget->setCellWidget(ui->tableWidget->rowCount() - 1, 0, item);
            ui->tableWidget->setRowHeight(ui->tableWidget->rowCount() - 1, textHeight);
        }
    }
    if(disconnect)
        parent->disconnectFromDatabase(&db);
}
コード例 #10
0
static QWidget *decorationFromWidget(QWidget *w)
{
    QLabel *label = new QLabel(0, Qt::ToolTip);
    QPixmap pm = w->grab(QRect(0, 0, -1, -1));
    label->setPixmap(pm);
    label->resize(pm.size());

    return label;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: Afreeca/qt
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QLabel label;
    label.resize(300, 200);
    label.setText(" This demo requires Mac OS X.");
    label.show();
    return app.exec();
}
コード例 #12
0
ファイル: formwindow_dnditem.cpp プロジェクト: sicily/qt4.8.4
static QWidget *decorationFromWidget(QWidget *w)
{
    QLabel *label = new QLabel(0, Qt::ToolTip);
    QPixmap pm = QPixmap::grabWidget(w);
    label->setPixmap(pm);
    label->resize(pm.size());

    return label;
}
コード例 #13
0
ファイル: main.cpp プロジェクト: CodeGamer/Labyrinth
int main(int argc, char* argv[])
{
	Worker *myWorker = new Worker();
	QApplication myApp(argc, argv);
	QLabel* myLabel = new QLabel(myWorker->_text);
	myLabel->resize(400, 30);
	myLabel->show();
	  
	return myApp.exec();
}
コード例 #14
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    
    QLabel *hello = new QLabel("This is a simple window");
    hello.resize(100, 30);
    
    hello.show();
    return app.exec();
}
コード例 #15
0
ファイル: back.cpp プロジェクト: navyzhou926/test.2
int main(int argc, char * argv[])
{
    QApplication app(argc, argv);

    QLabel *win = new QLabel("<center><font color = #0000ff><h1><i>Waiting order....</i>""</font></h1></center>");
    win->resize(800,480);
    win->show();

    app.exec();
}
コード例 #16
0
void CmdTestGrabWidget::activated(int iMsg)
{
    QCalendarWidget* c = new QCalendarWidget();
    c->hide();
    QPixmap p = QPixmap::grabWidget(c, c->rect());
    QLabel* label = new QLabel();
    label->resize(c->size());
    label->setPixmap(p);
    label->show();
    delete c;
}
コード例 #17
0
ファイル: main.cpp プロジェクト: Esclapion/qt-mobility
QTM_USE_NAMESPACE //(2)

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QSystemInfo s;
    QLabel *label = new QLabel(QObject::tr("hello ").append(s.currentCountryCode()));
    label->show();
    label->resize(100,30);
    return app.exec();
}
コード例 #18
0
ファイル: easygx_control_.cpp プロジェクト: edgarliu/easygx
egx_wnd_t egx_label_create_(int res_id,char *name,egx_uint32_t style,int x,int y,int width,int height,egx_wnd_t parent)
{
	QLabel *label = new QLabel((QWidget*)(parent));
	label->setText(QString::fromLocal8Bit(name));
	if(x == 0 || y == 0){
		label->resize(width,height);
	}else{
		label->setGeometry(x,y,width,height);
	}
	return HWND_TO_GUIWND(label);
}
コード例 #19
0
ファイル: statusscreen.cpp プロジェクト: hansj66/Jeeves
void StatusScreen::RefreshLayout()
{
    Builds builds = m_builders->builds();
    int nCount = builds.count();
    if (nCount == 0)
        return;


    if (m_discoveredBuilds != nCount)
    {
        m_discoveredBuilds = nCount;
        m_DisplayLines.clear();
        m_Icons.clear();

        m_lineHeight = (height()-14* nCount) / nCount;

        QVBoxLayout * layout = new QVBoxLayout();
        for (int i=0; i<nCount; i++)
        {
            QHBoxLayout * line = new QHBoxLayout();
            QPixmap image;
            Build::TARGET_OS os = builds.at(i)->Target();
            switch (os)
            {
                case Build::Windows: image = QPixmap(":/resources/windows-logo.png"); break;
                case Build::Mac: image = QPixmap(":/resources/osx_logo.jpg"); break;
                case Build::Linux: image = QPixmap(":/resources/linux-logo.jpg"); break;
                default: image = QPixmap(":/resources/undefined.png");
            }

            QLabel * label = new QLabel(this);
            QPixmap scaled = image.scaledToHeight(m_lineHeight);

            label->setPixmap(scaled);
            label->resize(50, 50);
            line->addWidget(label);

            QLineEdit * pEdit = new QLineEdit(this);
            pEdit->setReadOnly(true);
            m_DisplayLines.push_back(pEdit);
            m_Icons.push_back(label);
            line->addWidget(pEdit);

            layout->addLayout(line);
        }
        m_mainWindow = new QWidget(this);
        m_mainWindow->setStyleSheet("QWidget {  background: white;}");
        m_mainWindow->setLayout(layout);
        setCentralWidget(m_mainWindow);

        InitDisplayMessage();
    }
 }
コード例 #20
0
ファイル: mainwindow.cpp プロジェクト: enbool/test4
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setAcceptDrops(true);
    QLabel *label = new QLabel(this);
    QPixmap pix(":/image/images/C_171.png");
    label->setPixmap(pix);
    label->resize(pix.size());
    label->move(100,100);
    label->setAttribute(Qt::WA_DeleteOnClose);
}
コード例 #21
0
ファイル: utility.cpp プロジェクト: JandunCN/AllInGithub
QLabel* Utility::addText(const QPoint &pos, const QString &text, int fontPixel, const QString &color, QWidget *parent)
{
    QLabel *lbl = new QLabel(parent);
    QFont ft = ygApp->font();
    ft.setPixelSize(fontPixel);
    QFontMetrics ftm(ft);
    lbl->resize(ftm.width(text), ftm.height());
    lbl->move(pos);
    lbl->setStyleSheet(QString("QLabel{background:transparent;  color:%1; font-size: %2px;}").arg(color).arg(fontPixel));
    lbl->setText(text);
    lbl->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);

    return lbl;
}
コード例 #22
0
ファイル: titlewidget.cpp プロジェクト: jhonconal/Weather
void TitleWIdget::setTitles(const QStringList &titles)
{
    _titles = titles;
    int currentIndex = 0;
    QList<QWidget* > labelList;
    foreach (QString title, _titles) {
        QLabel *label = new QLabel(title,_horizonalSlider);
        label->setStyleSheet(DARK_STYLE);
        label->resize(_horizonalSlider->width(),_horizonalSlider->height());
        label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        QFont font("Tahoma",20);
        label->setFont(font);
        labelList.append(label);
    }
コード例 #23
0
ファイル: imagehandler.cpp プロジェクト: jonghough/QtCV
/**
 * @brief ImageHandler::setImage
 * @param qLabel
 * @param image
 */
void ImageHandler::setImage(QLabel& qLabel, cv::Mat image, QImage::Format imageFormat){
    cv::Mat convertIm;
    //convert to RGB for QT labels
    if(image.channels() > 1)
        cv::cvtColor(image, convertIm, CV_BGR2RGB);
    else
        convertIm = image;
    //refit the Mat to fit inside the QLabel
    convertIm = refit(qLabel.size(), convertIm);
    QImage im = QImage((const unsigned char*) (convertIm.data),
                       convertIm.cols, convertIm.rows,convertIm.step, imageFormat);
    qLabel.setPixmap(QPixmap::fromImage(im));
    qLabel.resize( qLabel.pixmap()->size());
}
コード例 #24
0
ファイル: paint_box.cpp プロジェクト: caomw/Opticks_Gsoc2013
paint_box::paint_box(std::string fname,std::string title,int row, int col,QWidget *parent):fname_(fname),
    QWidget(parent)
{
    ME=0;
    resize(col,row);
    QImage img1 = QImage(fname.c_str());
    QLabel *myLabel = new QLabel("",this);
    myLabel->setPixmap(QPixmap::fromImage(img1));

    myLabel->resize(row,col);
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->addWidget(myLabel);
    //    this->setWindowTitle(title.c_str());
    //    this->showNormal();

}
コード例 #25
0
ファイル: main.cpp プロジェクト: disgraceful/cpp-kpzFULL
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
//-----------------------
           QWidget MainWindows;
           MainWindows.setStyleSheet(
                                                    " QWidget   { font-size: 17px;  color :#65ED64; background-color: #777777;  border: 7px solid #64EB8D; }"
                                                  );
//-----------------------

           QLabel      *ptLabel         = new QLabel(&MainWindows);
           QPushButton *ptButton    = new QPushButton(&MainWindows);
           Counter     counter;

  ptLabel->move(25,25);
  ptLabel->setText(" T");
  ptLabel->resize(150,150);
  ptLabel->setStyleSheet(
                              "QLabel   { font-size: 80px;  color :#65ED64; background-color: #0C9F1D;  border: 7px solid #64EB8D; }"
                              );

  ptButton->move(180,25);
  ptButton->setText("  Add   ");
   ptButton->resize(150,150);
  ptButton->setStyleSheet(
                            "QPushButton   { font-size: 40px;  color :#65ED64; background-color: #0C9F1D;  border: 7px solid #64EB8D; }"
                             );
//  label.show();
//  button.show();

  QObject::connect(ptButton, SIGNAL(clicked()),
                   &counter, SLOT(slotInc())
                   );
  QObject::connect(&counter, SIGNAL(counterChanged(int)),
                   ptLabel, SLOT(setNum(int))
                   );
  QObject::connect(&counter, SIGNAL(goodbye()),
                   &app, SLOT(quit())
                   );

MainWindows.resize(350, 200);
MainWindows.show();

  return app.exec();
}
コード例 #26
0
ファイル: imageproxyitem.cpp プロジェクト: legnaleurc/komix
void ImageProxyItem::Private::onFinished(int /*id*/, QMovie * movie) {
    QLabel * label = new QLabel;
    label->setMovie(movie);
    movie->setParent(label);
    movie->start();
    label->resize(movie->frameRect().size());
    QGraphicsProxyWidget * item = new QGraphicsProxyWidget(this->owner);
    item->setWidget(label);
    // HACK workaround for https://bugreports.qt.io/browse/QTBUG-55070
    item->setOpacity(0.99);

    this->movie = movie;
    this->item = item;

    this->activity = Activity::Activated;

    emit this->owner->activated(this->owner);
}
コード例 #27
0
ファイル: mainwindow.cpp プロジェクト: enbool/test4
//放下事件
void MainWindow::dropEvent(QDropEvent *event)
{
    if(event->mimeData()->hasFormat("image/png")){
        QByteArray itemData;
        QDataStream dataStream(&itemData, QIODevice::ReadOnly);
        QPixmap pixmap;
        QPoint offset;
        dataStream>>pixmap>>offset;
        QLabel *newLabel = new QLabel(this);
        newLabel->setPixmap(pixmap);
        newLabel->resize(pixmap.size());
        newLabel->move(event->pos()-offset);
        newLabel->show();
       // newLabel->setAttribute(Qt::WA_DeleteOnClose);
        event->setDropAction(Qt::MoveAction);
        event->accept();

    }else{
コード例 #28
0
ファイル: kmacctpop.cpp プロジェクト: kthxbyte/KDE1-Linaro
KMPasswdDialog::KMPasswdDialog(QWidget *parent, const char *name, 
			       KMAcctPop *account , const char *caption,
			       const char *login, QString passwd)
  :QDialog(parent,name,true)
{
  // This function pops up a little dialog which asks you 
  // for a new username and password if one of them was wrong or not set.

  kbp->idle();

  act = account;
  setMaximumSize(300,180);
  setMinimumSize(300,180);
  setCaption(caption);

  QLabel *label = new QLabel(this);
  label->setText(i18n("Login Name:"));
  label->resize(label->sizeHint());

  label->move(20,30);
  usernameLEdit = new QLineEdit(this,"NULL");
  usernameLEdit->setText(login);
  usernameLEdit->setGeometry(100,27,150,25);
  
  QLabel *label1 = new QLabel(this);
  label1->setText(i18n("Password:"******"NULL");
  passwdLEdit->setEchoMode(QLineEdit::Password);
  passwdLEdit->setText(passwd);
  passwdLEdit->setGeometry(100,76,150,25);
  connect(passwdLEdit,SIGNAL(returnPressed()),SLOT(slotOkPressed()));

  ok = new QPushButton(i18n("OK") ,this,"NULL");
  ok->setGeometry(55,130,70,25);
  connect(ok,SIGNAL(pressed()),this,SLOT(slotOkPressed()));

  cancel = new QPushButton(i18n("Cancel"), this);
  cancel->setGeometry(180,130,70,25);
  connect(cancel,SIGNAL(pressed()),this,SLOT(slotCancelPressed()));

}
コード例 #29
0
ファイル: gamepainter.cpp プロジェクト: aganur-ahundov/Snake
GamePainter::GamePainter(QWidget *parent) : QWidget(parent)
{
    m_cellSize = QSize( 30, 30 );
    m_field    = new Field( 15, 15 );
    m_snake    = new Snake( QPoint( 7, 7) );
    m_IsPlay   = false;
    m_gameTimer = new QTimer;
    m_gameSpeed = 160;
    m_score     = 0;

    resize( m_cellSize.width() * ( m_field->getNumWCells() - 2 )
            , m_cellSize.height() * (m_field->getNumHCells() - 2 ) + 30 );


    QPixmap background("../snake_work_version/background.jpg" );
    background.scaled( this->size() );

    QPalette p;
    p.setBrush( this->backgroundRole(), QBrush( background ) );
    this->setPalette(p);

    QIcon windowIcon("../snake_work_version/icon1.png");
    window()->setWindowTitle("Snake");
    window()->setWindowIcon( windowIcon );

    connect( m_snake, SIGNAL(newStep(QPoint,QPoint)), m_field, SLOT(snake_move(QPoint,QPoint)) );
    connect( m_field, SIGNAL(snake_dead()), SLOT(snake_die()) );
    connect( m_field, SIGNAL(snake_ate()), SLOT(snake_eat()));
    connect( m_gameTimer, SIGNAL(timeout()), SLOT(game()) );

    m_settings  = new QSettings( "HOME", "Snake" );
    m_highScore = m_settings->value( HIGH_SCORE_KEY, 0 ).toInt() ;


    QLabel* high_score = new QLabel("<font face=\"mv boli\" color=#40E0D0><strong>High Score: </strong></font>", this );
    high_score->move( 20, -160  );
    high_score->resize( 300, 350 );

    QLabel* score = new QLabel("<font face=\"mv boli\" color=#40E0D0><strong>Score: </strong></font>", this );
    score->move( width() - 100, -160  );
    score->resize( 300, 350 );

    srand(time(0));
}
コード例 #30
0
bool ModelSelectionPane::PaneIndexDraw()
{
    if((m_curPaneIndex >= m_paneIndexCount) || (m_curPaneIndex < 0) || (OnAnimation()))
        return false;

    if(m_paneIndexCount > 0) {
        int indexPaneW = INDEX_ITEM_SPACE*(m_paneIndexCount+2);
        int indexPaneH = INDEX_PANE_HEIGHT;
        int indexPaneX = (width() - indexPaneW)/2;
        int indexPaneY = ui->indexwidget->y();

        ui->indexwidget->setVisible(true);
        ui->indexwidget->setGeometry(indexPaneX, indexPaneY, indexPaneW, indexPaneH);

        // new index labels
        if(m_indexLabelList.count() < m_paneIndexCount) {
            int mallocLabelCount = m_paneIndexCount - m_indexLabelList.count();
            for(int i = 0; i < mallocLabelCount; i++) {
                QLabel* pIndexLabel = new QLabel(ui->indexwidget);
                pIndexLabel->resize(INDEX_PIXMAP_RADIUS*2, INDEX_PIXMAP_RADIUS*2);
                m_indexLabelList.append(pIndexLabel);
            }
        }

        int x = 0;
        int y = 0;
        for(int i = 0; i < m_indexLabelList.count(); i++) {
            if(i < m_paneIndexCount) {
                m_indexLabelList[i]->setVisible(true);
                m_indexLabelList[i]->setPixmap(i == m_curPaneIndex ? m_selectedPix : m_unselectedPix);
                x = INDEX_ITEM_SPACE*(i+1) - INDEX_PIXMAP_RADIUS;
                y = (INDEX_PANE_HEIGHT - INDEX_PIXMAP_RADIUS*2) / 2;
                m_indexLabelList[i]->move(x, y);
            } else {
                m_indexLabelList[i]->setVisible(false);
            }
        }
    } else {
        ui->indexwidget->setVisible(false);
    }

    return true;
}