MatrixViewDialog::MatrixViewDialog(std::shared_ptr<Matrix<int>>& matrix, int pos, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MatrixViewDialog),
    data(matrix),
    _pos(pos)
{
    ui->setupUi(this);
    setWindowTitle(QString::fromStdString(matrix->toStr()) + " info");

    ui->tableWidget->setRowCount(matrix->rows());
    ui->tableWidget->setColumnCount(matrix->columns());
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    for (size_t i = 0; i < matrix->rows(); ++i) {
        for (size_t j = 0; j < matrix->columns(); ++j) {
            auto tmpItem = new QTableWidgetItem;

            auto tmpStr = QString::fromStdString(std::to_string((*matrix)(i,j)));
            tmpItem->setText(tmpStr);
            tmpItem->setTextAlignment(Qt::AlignCenter);
            ui->tableWidget->setItem(i, j, tmpItem);
        }
    }

    connect(ui->saveBtn, SIGNAL(clicked()), SLOT(saveBtnClicked()));
    connect(ui->removeBtn, SIGNAL(clicked()), SLOT(removeBtnClicked()));
}
void deleteusersdialog::setUpSubviews() {
    main_layout = new QVBoxLayout;

    box = new QComboBox;

    QFormLayout* form = new QFormLayout;
    form->addRow("删除用户: ", box);
    main_layout->addLayout(form);

    QHBoxLayout* btn_layout = new QHBoxLayout;
    btn_layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));

    QPushButton* save_btn = new QPushButton("删除");
    QObject::connect(save_btn, SIGNAL(released()), this, SLOT(saveBtnClicked()));
    btn_layout->addWidget(save_btn);

    btn_layout->addSpacerItem(new QSpacerItem(30, 0, QSizePolicy::Fixed, QSizePolicy::Minimum));

    QPushButton* cancal_btn = new QPushButton("取消");
    QObject::connect(cancal_btn, SIGNAL(released()), this, SLOT(cancelBtnClicked()));
    btn_layout->addWidget(cancal_btn);

    btn_layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));

    main_layout->addLayout(btn_layout);

    this->setLayout(main_layout);

    QObject::connect(proxymanager::instance()->getConfigProxy(), SIGNAL(queryLstDoctorsSuccess(QJsonArray)),
                     this, SLOT(queryLstDoctorsSuccess(QJsonArray)));

    proxymanager::instance()->getConfigProxy()->lstUsers();
}
Example #3
0
MyChat::MyChat(ClientInfo &c, QWidget* parent):QWidget(parent)
{
    this->clientInfo = c;

    this->resize(588, 512);

    showText = new QTextBrowser();
//    showText->setGeometry(10,10,566,290);

    inputText = new QTextEdit();
//    inputText->setGeometry(10,320,566,80);

    closeBtn = new QPushButton();
    closeBtn->setText("Close");
    sendBtn = new QPushButton();
    sendBtn->setText("Send");

    fontHomeBox = new QFontComboBox();
    fontHomeBox->setEditable(false);

    fontSizeBox = new QComboBox();
    QStringList sizeList;
    sizeList<<"9"<<"10"<<"11"<<"12"<<"13"<<"14"<<"15"<<"16"<<"17"<<"18"<<"19"<<"20"<<"21"<<"22";
    fontSizeBox->insertItems(0, sizeList);
    fontSizeBox->setCurrentIndex(3);

    boldToolBtn = new QToolButton();
    boldToolBtn->setCheckable(true);//可以按下
    boldToolBtn->setIcon(QIcon(":/root/chatIcon/bold.png"));
    boldToolBtn->setIconSize(QSize(32,32));
    boldToolBtn->setAutoRaise(true);

    italicToolBtn = new QToolButton();
    italicToolBtn->setCheckable(true);
    italicToolBtn->setIcon(QIcon(":/root/chatIcon/italic.png"));
    italicToolBtn->setIconSize(QSize(32,32));
    italicToolBtn->setAutoRaise(true);

    underlineToolBtn = new QToolButton();
    underlineToolBtn->setCheckable(true);
    underlineToolBtn->setIcon(QIcon(":/root/chatIcon/underline.png"));
    underlineToolBtn->setIconSize(QSize(32,32));
    underlineToolBtn->setAutoRaise(true);

    colorToolBtn = new QToolButton();
    colorToolBtn->setIcon(QIcon(":/root/chatIcon/color.png"));
    colorToolBtn->setIconSize(QSize(32,32));
    colorToolBtn->setAutoRaise(true);

    sendToolBtn = new QToolButton();
    sendToolBtn->setIcon(QIcon(":/root/chatIcon/sendfile.png"));
    sendToolBtn->setIconSize(QSize(32,32));
    sendToolBtn->setAutoRaise(true);

    saveToolBtn = new QToolButton();
    saveToolBtn->setIcon(QIcon(":/root/chatIcon/savemsg.png"));
    saveToolBtn->setIconSize(QSize(32,32));
    saveToolBtn->setAutoRaise(true);

    clearToolBtn = new QToolButton();
    clearToolBtn->setIcon(QIcon(":/root/chatIcon/clearmsg.png"));
    clearToolBtn->setIconSize(QSize(32,32));
    clearToolBtn->setAutoRaise(true);

    QHBoxLayout* h2 = new QHBoxLayout();
    h2->addWidget(fontHomeBox);
    h2->addWidget(fontSizeBox);
    h2->addWidget(boldToolBtn);
    h2->addWidget(italicToolBtn);
    h2->addWidget(underlineToolBtn);
    h2->addWidget(colorToolBtn);
    h2->addWidget(sendToolBtn);
    h2->addWidget(saveToolBtn);
    h2->addWidget(clearToolBtn);

    QVBoxLayout* v1 = new QVBoxLayout();
    v1->addWidget(showText, 6);
    v1->addLayout(h2);
    v1->addWidget(inputText, 2);
//    v1->addStretch(3);

    QHBoxLayout* h1 = new QHBoxLayout();
    h1->addWidget(closeBtn, 0);
    h1->addWidget(sendBtn, 0);
    h1->setAlignment(Qt::AlignHCenter | Qt::AlignRight);
//    h1->addStretch();

    QVBoxLayout* v2 = new QVBoxLayout(this);
    v2->addLayout(v1);
    v2->addLayout(h1);

    connect(sendBtn,SIGNAL(clicked()), this, SLOT(sendMsg()));
    connect(closeBtn, SIGNAL(clicked()), this, SLOT(closeClicked()));
    connect(fontHomeBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(fontHomeChange()));
    connect(fontSizeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(fontSizeChange()));
    connect(boldToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontBoldChange()));
    connect(italicToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontItalicChange()));
    connect(underlineToolBtn, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChange()));
    connect(colorToolBtn, SIGNAL(clicked()), this,SLOT(colorBtnClicked()));
    connect(saveToolBtn, SIGNAL(clicked()), this, SLOT(saveBtnClicked()));
    connect(clearToolBtn, SIGNAL(clicked()), this, SLOT(clearBtnClicked()));
    //当单击输入框中一个字体时,字体格式设置会变成设置这个字体时的设置
    connect(inputText, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(fontFormatChanged(const QTextCharFormat)));

    mySocket = MySocket::getInstance();
}