Пример #1
0
FormLoadParam::FormLoadParam(QWidget *parent, QLayout *layout) :
    MtcOpWidget(parent, layout),
    ui(new Ui::FormLoadParam)
{
    ui->setupUi(this);
    connect(getParamMgr(), SIGNAL(FileLoadSuccess(int)), this, SLOT(ShowFileInfo(int)), Qt::QueuedConnection);
    connect(getReqParam(), SIGNAL(ShowDownloadingFile(quint32)),
            this, SLOT(ShowDownloading(quint32)));
    connect(getReqParam(), SIGNAL(ShowPreDownloadResult(quint32,bool,bool)),
            this, SLOT(ShowPreDownload(quint32,bool,bool)));
    connect(getReqParam(), SIGNAL(ShowDownloadedResult(quint32,bool,bool)),
            this, SLOT(ShowDownloaded(quint32,bool,bool)));
    connect(getReqParam(), SIGNAL(LoadFinish(int, bool)),
            this, SLOT(ShowFileInfo(int)));

    //TODO_liubo
    /*ui->tableWidget->horizontalHeader()->resizeSection(0,144);
    ui->tableWidget->horizontalHeader()->resizeSection(1,105);
    ui->tableWidget->horizontalHeader()->resizeSection(2,96);
    ui->tableWidget->horizontalHeader()->resizeSection(3,144);*/
    //ui->tableWidget->horizontalHeader()->resizeSection(4,78);
    ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

    QHeaderView *headerView = ui->tableWidget->verticalHeader();
    headerView->setHidden(true);

}
Пример #2
0
QTServer::QTServer(QWidget *parent)
    : QMainWindow(parent) {
    ui.setupUi(this);

    //
    GlobalAddAtom("shitnow");

    //设置表头及大小
    QStringList header;
    header << QStringLiteral("账号") << QStringLiteral("大区") << QStringLiteral("服务器") << QStringLiteral("脚本")
        << QStringLiteral("角色") << QStringLiteral("金币") << QStringLiteral("地图") << QStringLiteral("状态");
    ui.tableWidget->setColumnCount(header.count());
    ui.tableWidget->setHorizontalHeaderLabels(header);
    //ui.tableWidget->setRowCount(20); // 设置行数
    ui.tableWidget->horizontalHeader()->setDefaultSectionSize(150);
    //ui.tableWidget->setColumnWidth(0, 150); //设置第一列宽度
    //ui.tableWidget->setColumnWidth(1, 150); //设置第二列宽度
    //ui.tableWidget->setColumnWidth(2, 150); //设置第三列宽度
    //ui.tableWidget->setColumnWidth(3, 150);
    //ui.tableWidget->setColumnWidth(4, 150);
    //ui.tableWidget->setColumnWidth(5, 150);
    //ui.tableWidget->setColumnWidth(6, 150);
    //ui.tableWidget->horizontalHeader()->setStretchLastSection(true); //将最后一列延伸到整个列表全满
    ui.tableWidget->horizontalHeader()->setSectionsClickable(false); //设置表头不可点击(默认点击后进行排序)
    ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // 所有列自适应窗口宽度

    //设置隔一行变一颜色,即:一灰一白
    ui.tableWidget->setAlternatingRowColors(true);

    //控件刚开始的时候左边默认自带序列号,如果想去掉左边的行号,加上下面的代码
    QHeaderView* headerView = ui.tableWidget->verticalHeader();
    headerView->setHidden(true);
    //设置默认行高
    //headerView->setDefaultSectionSize(30);

    //整行选中的方式
    ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);

    //不能对表格内容进行修改
    ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);

    m_tcpServer = new QTcpServer(this);
    m_tcpServer->listen(QHostAddress::Any, 12589); //监听任何连上12589端口的ip
    connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(SlotNewConnect()));

    //菜单栏关联
    connect(ui.actionAddAccount, SIGNAL(triggered()), this, SLOT(SlotAddAccount()));
    connect(ui.actionOption, SIGNAL(triggered()), this, SLOT(SlotOptionSet()));
    connect(ui.actionExportAcc, SIGNAL(triggered()), this, SLOT(SlotExportAcc()));
    connect(ui.actionImportAcc, SIGNAL(triggered()), this, SLOT(SlotImportAcc()));
    connect(ui.tableWidget, &CMyTableWidget::SignalSendAddAcc, this, &QTServer::SlotAddAcc);

    // 以下为设置游戏路径
    SlotInitGamePath();

    // 列表框關聯
    QObject::connect(ui.tableWidget, &CMyTableWidget::SignalStartNewGame, this, &QTServer::SlotStartNewGame);
    QObject::connect(ui.tableWidget, &CMyTableWidget::SignalStopScript, this, &QTServer::SlotStopScript);
    QObject::connect(ui.tableWidget, &CMyTableWidget::SignalStartScript, this, &QTServer::SlotStartScript);
}
Пример #3
0
TableView::TableView(QWidget * parent) : QTableView(parent)
{
	QHeaderView * header = verticalHeader();
	header->setHidden(true);

	header = horizontalHeader();
	header->setClickable(false);
	header->setDragEnabled(false);
	header->setResizeMode(QHeaderView::Fixed);
}
//int newWordManageWindow::newWordList.size() = 0;
newWordManageWindow::newWordManageWindow(User *user):user(user)
{
    row = 13;
    column = 3;
    currentPage = 1;
    TotalPages = newWordList.size()/row+1;
    this->setMaximumSize(270, 480);
    this->setMinimumSize(270, 480);
    this->setWindowFlags(Qt::FramelessWindowHint);
    background =  new QLabel(this);
    background->setStyleSheet("background:url(:/image/wordManage.jpg)");
    background->setGeometry(0, 0, this->width(), this->height());

    tableWidget = new QTableWidget(row, column);
    tableWidget->setParent(this);
    tableWidget->setGeometry(22, 80, 226, 326);
    QStringList headerList;
    headerList << "单词"  << "解释" << "加入时间";
    tableWidget->setHorizontalHeaderLabels(headerList);
    tableWidget->setColumnWidth(0, 60);
    tableWidget->setColumnWidth(1, 82);
    tableWidget->setColumnWidth(2, 82);
    for(int i=0; i<row; i++)
    {
        tableWidget->setRowHeight(i, 23);
    }
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    tableWidget->setShowGrid(false);
    QHeaderView *headerview = tableWidget->verticalHeader();
    headerview->setHidden(true);
    tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    QTableWidgetItem *item1, *item2, *item3;
    for(int i=0; i<row; i++)
    {
            item1 = new QTableWidgetItem("");
            item2 = new QTableWidgetItem("");
            item3 = new QTableWidgetItem("");
            item1->setTextAlignment(Qt::AlignCenter);
            item2->setTextAlignment(Qt::AlignCenter);
            item3->setTextAlignment(Qt::AlignCenter);

            tableWidget->setItem(i, 0, item1);
            tableWidget->setItem(i, 1, item2);
            tableWidget->setItem(i, 2, item3);

    }
    remindLabel = new QLabel(this);
    addButton = new QPushButton(this);
    deleteButton = new QPushButton(this);
    preButton = new QPushButton(this);
    backButton = new QPushButton(this);
    nextButton = new QPushButton(this);

    backButton->setGeometry(10, 6, 40, 19);
    remindLabel->setGeometry(173, 30, 24, 40);
    remindLabel->setText("0");
    remindLabel->setStyleSheet("font-size:20px");
    remindLabel->setAlignment(Qt::AlignBottom|Qt::AlignHCenter);
    addButton->setGeometry(94, 419, 80, 35);
    deleteButton->setGeometry(175, 419, 80, 35);
    preButton->setGeometry(2, 210, 17, 33);
    nextButton->setGeometry(251, 210, 17, 33);
    addButton->setStyleSheet("background-color:transparent");
    deleteButton->setStyleSheet("background-color:transparent");
    preButton->setStyleSheet("background-color:transparent");
    nextButton->setStyleSheet("background-color:transparent");
    backButton->setStyleSheet("background-color:transparent");
    addDialog = new dialog(this);
    pageLabel = new QLabel(this);
    pageLabel->setGeometry(32, 410, 100, 40);
    QString string1 = QString::number(currentPage);
    QString string2 = QString::number(TotalPages);
    QString string = string1 + "/" + string2;
    pageLabel->setText(string);
    connect(addButton, SIGNAL(clicked()), addDialog, SLOT(show()));
    connect(addDialog->ensureButton, SIGNAL(clicked()), this, SLOT(add()));
    connect(addDialog->ensureButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteRow()));
    connect(backButton, SIGNAL(clicked()), this, SLOT(back()));
    connect(preButton, SIGNAL(clicked()), this, SLOT(prePage()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(nextPage()));

}