小编Mic*_*003的帖子

Qt捕捉复选框的信号以执行操作

在我的Qt程序中,我想抓住我的一个复选框的信号,知道它是否被检查过.我做的 :

#include <iostream>
#include <QVBoxLayout>
#include <QtGui>
#include "Window.h"

Window::Window() : QWidget()
{
  setFixedSize(400, 800);

  m_bouton = new QPushButton("Module 1");
  m_bouton->setCursor(Qt::PointingHandCursor);

  m_bouton2 = new QPushButton("Module 2");
  m_bouton2->setCursor(Qt::PointingHandCursor);

  m_bouton3 = new QPushButton("Module 3");
  m_bouton3->setCursor(Qt::PointingHandCursor);

  m_bouton4 = new QPushButton("Module 4");
  m_bouton4->setCursor(Qt::PointingHandCursor);

  m_check4 = new QCheckBox(this);
  m_check4->move(300, 50);
  m_check4->setChecked(true);

  m_check3 = new QCheckBox(this);
  m_check3->move(200, 50);
  m_check3->setChecked(true);

  m_check2 = new QCheckBox(this);
  m_check2->move(100, 50);
  m_check2->setChecked(true);

  m_check1 = new QCheckBox(this);
  m_check1->move(0, 50);
  m_check1->setChecked(true);

  QVBoxLayout *layout = new QVBoxLayout;
  layout->addWidget(m_bouton);
  layout->addWidget(m_bouton2);
  layout->addWidget(m_bouton3);
  layout->addWidget(m_bouton4);
  this->setLayout(layout);
  this->setStyleSheet("border: 1px …
Run Code Online (Sandbox Code Playgroud)

c++ qt

7
推荐指数
1
解决办法
5836
查看次数

管理转义键以退出程序

我不知道如何实现退出键的管理以退出程序.我不知道在我的代码中把它放在哪里,因为如果我把它放在一个方法中,它怎么能在任何地方退出?

这是我的实际代码:

    #include <iostream>
    #include <QApplication>
    #include <QPushButton>
    #include <QLineEdit>
    #include <QFormLayout>
    #include <QDebug>
    #include "LibQt.hpp"

    LibQt::LibQt() : QWidget()
    {
      this->size_x = 500;
      this->size_y = 500;
      QWidget::setWindowTitle("The Plazza");
      setFixedSize(this->size_x, this->size_y);
      manageOrder();
    }

    LibQt::~LibQt()
    {
    }
void LibQt::manageOrder()
{
  this->testline = new QLineEdit;
  this->m_button = new QPushButton("Send Order");
  QFormLayout *converLayout = new QFormLayout;

  this->m_button->setCursor(Qt::PointingHandCursor);
  this->m_button->setFont(QFont("Comic Sans MS", 14));
  converLayout->addRow("Order : ", this->testline);
  converLayout->addWidget(this->m_button);
  this->setLayout(converLayout);
  QObject::connect(m_button, SIGNAL(clicked()), this, SLOT(ClearAndGetTxt()));
}

std::string     LibQt::ClearAndGetTxt()
{
  QString txt = this->testline->text();

  this->usertxt = txt.toStdString();
  std::cout << …
Run Code Online (Sandbox Code Playgroud)

c++ events qt key keyevent

5
推荐指数
1
解决办法
751
查看次数

匹配后 Ansible 插入行

我试图在文件最后一次匹配正则表达式后在文件中插入一行。它实际上是在文件末尾添加行。

  tasks:
  - name: add to ansible hosts file
    lineinfile:
      dest: "hosts"
      insertafter: '^\[ansible_ssh_host\]'
      line: " test ansible_ssh_host=172.0.0.3"
Run Code Online (Sandbox Code Playgroud)

我希望在包含“ansible_ssh_host”的最后一行之后添加它

目标文件

ansible-server ansible_ssh_host=172.0.0.1
template-server ansible_ssh_host=172.0.0.2

[tag_ansible-servers]
ansible-server

[tag_template-servers]
template-server   
Run Code Online (Sandbox Code Playgroud)

text ansible

3
推荐指数
1
解决办法
7617
查看次数

标签 统计

c++ ×2

qt ×2

ansible ×1

events ×1

key ×1

keyevent ×1

text ×1