Help to understand



  • "Your text to link here...":http://cs408928.vk.me/v408928011/6053/XlvHjEnX8Eg.jpg
    @
    #include <QtGui>
    #include <iostream>
    #include <string>
    #include <typeinfo>
    #include "b.h"
    #include <QPixmap>
    #include <QStyle>

    class Game;
    class QPixmap;

    Canvas::Canvas(QWidget *parent) : QWidget(parent)
    {

    startButton = new QPushButton(tr("&Start"));
    hitButton = new QPushButton(tr("&Hit"));
    standButton = new QPushButton(tr("&Stand"));

    connect(startButton, SIGNAL(clicked()), this, SLOT(startBtn()));
    connect(hitButton, SIGNAL(clicked()), this, SLOT(hitBtn()));
    connect(standButton, SIGNAL(clicked()), this, SLOT(standBtn()));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(startButton);
    buttonLayout->addWidget(hitButton);
    buttonLayout->addWidget(standButton);

    buttonLayout->addStretch();

    QPixmap tablePix;
    tablePix.load("://images/table.png");
    
    
    cardTable = new QListView;
    
    QLabel *houseLabel = new QLabel(cardTable);
    QLabel *playerLabel = new QLabel(cardTable);
    
    houseLabel->setText("House");
    playerLabel->setText("Player");
    houseLabel->move(10,20);
    playerLabel->move(10,150);
    

    QVBoxLayout *verticalLayout = new QVBoxLayout;
    verticalLayout->addLayout(buttonLayout);
    verticalLayout->addWidget(cardTable);
    hostState = new QLabel("host");
    playerState = new QLabel("player");
    result = new QLabel("result");
    verticalLayout->addWidget(hostState);
    verticalLayout->addWidget(playerState);
    verticalLayout->addWidget(result);

    QGridLayout *mainLayout = new QGridLayout;

    mainLayout->addLayout(verticalLayout, 0,0,1,1);

    setLayout(mainLayout);

    setWindowTitle(tr("Warezovvv BlackJack "));
    resize(710,480);
    

    // Disable Hit/Stand buttons initially
    setEnableHitStandButtons(false);
    setupIcons();
    }

    void Canvas::setEnableHitStandButtons(bool b)
    {
    hitButton->setEnabled(b);
    standButton->setEnabled(b);
    }

    void Canvas::setupIcons()
    {
    QPixmap qpx ;
    string str;

        for (int i = 0; i < MAXCARDS; i++) {
    

    cardIconHouse[i] = new QLabel(cardTable);
    str = ":/images/blank.png";
    qpx = QPixmap(str.c_str());
    cardIconHouse[i]->setPixmap(qpx);
    cardIconHouse[i]->move(80+60*i,20);
    }

        for (int i = 0; i < MAXCARDS; i++) {
    

    cardIconPlayer[i] = new QLabel(cardTable);
    qpx = QPixmap(":/images/blank.png");
    cardIconPlayer[i]->setPixmap(qpx);
    cardIconPlayer[i]->move(80+60*i,150);
    }
    }

    void Canvas::clearIcons()
    {
    QPixmap qpx = QPixmap(":/images/blank.png");
    for (int i = 0; i < MAXCARDS; i++) {
    cardIconHouse[i]->setPixmap(qpx);
    }

        for (int i = 0; i < MAXCARDS; i++) {
    

    cardIconPlayer[i]->setPixmap(qpx);
    }
    }

    void Canvas::startBtn()
    {
    vector<string> names;
    string name = "You";
    names.push_back(name);

     //the game 
     myGame = new Game(names,this);
    
     // initial table setup
     myGame->gameStarted();
    

    setEnableHitStandButtons(true);
    }

    void Canvas::hitBtn()
    {
    myGame->hitSelected();
    }

    void Canvas::standBtn()
    {
    myGame->standSelected();

    }

    void Canvas::setHostStateLabel(QString &s)
    {
    hostState->setText(s);
    }

    void Canvas::setPlayerStateLabel(QString &s)
    {
    playerState->setText(s);
    }

    void Canvas::setResultLabel(QString &s)
    {
    result->setText(s);
    }

    void Canvas::drawCards(AbstractPlayer &ap)
    {
    QPixmap qpx ;
    if(typeid(ap) == typeid(Player)) {
    Player *ptr = dynamic_cast<Player *> (&ap);
    int size = (ptr->getPixmaps()).size();
    for(int i = 0; i < size ; i++) {
    qpx = (ptr->getPixmaps())[i];
    cardIconPlayer[i]->setPixmap(qpx);
    }
    }
    else if(typeid(ap) == typeid(House)) {
    House *ptr = dynamic_cast<House *> (&ap);
    int size = (ptr->getPixmaps()).size();
    for(int i = 0; i < size ; i++) {
    qpx = (ptr->getPixmaps())[i];
    cardIconHouse[i]->setPixmap(qpx);
    }
    }
    }

    @

    I think it's creating in c.cpp but where. I want to delete white screen and borders and add image (blackjack table)
    p.s. it's not my code. I just want to understand Qt with help of different codes. I understand all all of code but cant find that white label



  • The decorations you are seeing are the visual representation of the QListView called cardTable.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.