#include <QPushButton>
#include <QWidget>
#include <QHBoxLayout>
#include <QSize>
#include <QGroupBox>
#include <QTextEdit>
#include <QIcon>
#include <QLabel>
#include <QDebug>
#include <QVBoxLayout>
class GameButton;
class GameButton : public QPushButton
{
public:
explicit GameButton(QWidget *parent = 0) : QPushButton(parent) {}
protected:
bool player;
};
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
QSize mainFrame, SizeButton, sizeChat, sizeEdit;
GameButton *but;
QHBoxLayout *firstLine, *mainLayout, *secondLine, *thirdLine;
QVBoxLayout *left, *right;
QTextEdit *edit;
QLabel *MainChat;
public slots:
void setupPicture_0();
};
MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
{
mainFrame.setHeight(400);
mainFrame.setWidth(600);
SizeButton.setHeight(50);
SizeButton.setWidth(50);
sizeChat.setHeight(300);
sizeChat.setWidth(200);
sizeEdit.setHeight(30);
sizeEdit.setWidth(200);
but = new GameButton[9];
/*______________________*/
/*Редакирование окна*/
this->setFixedSize(mainFrame);
this->setWindowTitle("erert");
/*______________________________*/
for (int i = 0; i < 9; i++)
but[i].setFixedSize(SizeButton);
/*________________________*/
firstLine = new QHBoxLayout;
left = new QVBoxLayout;
right = new QVBoxLayout;
mainLayout = new QHBoxLayout;
edit = new QTextEdit;
secondLine = new QHBoxLayout;
thirdLine = new QHBoxLayout;
MainChat = new QLabel;
/*__________________________*/
firstLine->addWidget(&but[0]);
firstLine->addWidget(&but[1]);
firstLine->addWidget(&but[2]);
/*__________________________*/
secondLine->addWidget(&but[3]);
secondLine->addWidget(&but[4]);
secondLine->addWidget(&but[5]);
/*___________________________*/
thirdLine->addWidget(&but[6]);
thirdLine->addWidget(&but[7]);
thirdLine->addWidget(&but[8]);
/*__________________________*/
MainChat->setFixedSize(sizeChat);
MainChat->setStyleSheet("color: rgb(50, 0, 70)");
MainChat->setText(">Player1: Hello! \n>Player2: Hello!!!\n");
edit->setFixedSize(sizeEdit);
right->addWidget(MainChat);
right->addWidget(edit);
left->addLayout(firstLine);
left->addLayout(secondLine);
left->addLayout(thirdLine);
mainLayout->addLayout(left);
mainLayout->addLayout(right);
this->setLayout(mainLayout);
/*_____________________*/
connect(&but[0], SIGNAL(clicked()), this, SLOT(setupPicture_0()));
}
MainWindow::~MainWindow()
{
}
void MainWindow::setupPicture_0()
{
but[0].setIcon(QIcon("1.png"));
}
Почему то при клике на кнопку не устанавливается иконка на кнопку. В чем проблема?