我正在尝试在Qt中创建一个圆形按钮.QPushButton在设计器中创建了一个带有单个按钮的简单表单.我正试图将它变成一个圆形按钮setMask().一旦setMask()应用,按钮就会消失.是否需要创建自定义窗口小部件来制作圆形按钮?
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QtGui/QPushButton>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->pushButton->setText("Test Text");
ui->pushButton->setFixedHeight(200);
ui->pushButton->setFixedWidth(200);
//Set Starting point of region 5 pixels inside , make region width & height
//values same and less than button size so that we obtain a pure-round shape
QRegion* region = new QRegion(*(new QRect(ui->pushButton->x()+5,ui->pushButton->y()+5,190,190)),QRegion::Ellipse);
ui->pushButton->setMask(*region);
ui->pushButton->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QMessageBox msgbox;
msgbox.setText("Text was set");
msgbox.show();
}
Run Code Online (Sandbox Code Playgroud)
注意:如果按钮是在代码中创建的,并且在显示窗口之前应用于窗口,则会显示该按钮.我想使用Qt …
我有一个带有10个TextBox的表单(CustomerInfoForm).Text每个默认属性TextBoxes都是在设计时定义的.子类CustomerInfoForm.CustomerInfo 包含用于保存在表单中输入的数据的属性.包含数据的子类将序列化为XML.
在自动生成的表单代码中,每个文本框都有一行代码将数据源绑定到文本框
this.customerInfoBindingSource = new System.Windows.Forms.BindingSource(this.components);
Run Code Online (Sandbox Code Playgroud)
每个文本框由C#ide自动生成的代码:
this.txtCustomer.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.customerInfoForm_CustomerInfoBindingSource, "CustomerName", true));
this.txtCustomer.Location = new System.Drawing.Point(60, 23);
this.txtCustomer.Name = "txtCustomer";
this.txtCustomer.Size = new System.Drawing.Size(257, 20);
this.txtCustomer.TabIndex = 0;
this.txtCustomer.Text = "CustomerName";
Run Code Online (Sandbox Code Playgroud)
(我注意到Text在IDE生成的代码中,直到DataBinding之后才设置该属性).
当我运行项目时,表单将显示为默认值TextBoxes.但是,当SaveButton按下序列MyForm.CustomerInfo化子类中的属性时,它们都为null.由于这些值只会从我希望我不必实现接口的表单中更改INotifyPropertyChanged.
我错过了一些基本或简单的东西吗?
包含数据序列化的表单代码如下
using System;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.IO;
using System.Runtime.Serialization;
namespace SimpleCustomerInfo
{
// You must apply a DataContractAttribute or SerializableAttribute
// to a class to have it serialized …Run Code Online (Sandbox Code Playgroud) 我正在尝试向Web服务发送JSON查询,并继续将内部服务器错误作为对查询的响应.
这是我要发送的内容:
POST /api/1.7/webservice.asmx HTTP/1.1
Host: www.superService.com
User-Agent: My app name v0.1
X-Custom-User-Agent: My app name v0.1
Content-Type: application/json
Content-Length:81
{"method":"AuthenticatePlain","loginName":"username@domain.com","password":"mypass"}
Run Code Online (Sandbox Code Playgroud)
这应该发送到 https://www.superService.com/api/1.7/ssapi.asmx
在准备QNetworkRequest时,使用什么方法来插入行
POST /api/1.7/webservice.asmx HTTP/1.1?
QNetworkRequest对象中是否包含完整的标头?
JSON数据应该在QNetworkRequest对象中,还是作为QNetworkAccessManager :: post()方法中的第二个参数添加到帖子中?
这是我在on_btnLogin_clicked()插槽中的当前代码:
connect(m_qnam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(handleNetworkData(QNetworkReply*)));
connect(m_qnam,SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
this, SLOT(handleSSLErrors(QNetworkReply*)));
QString baseString = "";
baseString.append(QString("POST /api/1.7/webservice.asmx HTTP/1.1\r\n").toUtf8());
baseString.append(QString("www.superService.com\r\n").toUtf8());
baseString.append(QString("User-Agent: My app name v0.1\r\n").toUtf8());
baseString.append(QString("X-Custom-User-Agent: My app name v0.1\r\n").toUtf8());
baseString.append(QString("Content-Type: application/json\r\n").toUtf8());
QString jsonString = QString("{");
jsonString.append("\"method\":");
jsonString.append("\"AuthenticatePlain\"");
jsonString.append(",\"loginName\":");
jsonString.append("\"username@domain.com\"");
jsonString.append(",\"password\":");
jsonString.append("\"mypass\"");
jsonString.append("}");
QByteArray json = jsonString.toUtf8();
baseString.append(QString("Content-Length:").toUtf8());
baseString.append(QString::number(json.length()));
baseString.append("\r\n").toUtf8();
baseString.append(QString("\r\n").toUtf8());
baseString.append(json); …Run Code Online (Sandbox Code Playgroud) 我正在尝试从我在Linux中运行的Qt应用程序运行命令行程序gphoto2,并读取它输出到标准输出和标准错误的结果.此概念验证程序中的GUI是单个按钮和标签,用于显示标准错误和标准输出的输出.
我在将QtProcess :: Finished信号连接到正确的插槽时遇到问题.我从头文件,连接语句和函数中的Finished()信号文档中复制了参数列表.函数名称以MainWindow :: class标识符为前缀.我已经没有什么可尝试的了,我希望StackOverflow中的某个人能够指出问题所在.
The Header file:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QString>
#include <QProcess>
#include <QObject>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void reply2();
private slots:
void on_pushButton_clicked();
void on_cameraControlExit(int exitCode, QProcess::ExitStatus exitStatus);
private:
Ui::MainWindow *ui;
QProcess* cameraControl;
};
#endif // MAINWINDOW_H
Run Code Online (Sandbox Code Playgroud)
mainwindow.cpp文件
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QShortcut>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this); …Run Code Online (Sandbox Code Playgroud) 我有一个使用 AutoItX 进行自动化的 C# 应用程序。此应用程序在我使用 Microsoft Visual Studio 2013 版本 3 编译的 Windows 8.1 x64 环境中运行良好。
我将应用程序代码的副本推送到 bitbucket 存储库并将其克隆到运行 Windows 7 x64 的计算机。安装了 AutoItX 3.14.2 版并选择了 32 位调用。该应用程序是使用 Visual Studio 2013 版本4编译的。
应用程序编译正常,但第一次使用 AutoIt 函数导致错误:
An unhandled exception of type 'System.DllNotFoundException' occurred in AutoItX3.Assembly.dll
Run Code Online (Sandbox Code Playgroud)
我尝试了以下步骤。该应用程序在每个步骤后都经过测试
尝试使用 regsrv32 手动注册 .dll
regsrv32 "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
卸载 VisualStudio 2013 R4 并尝试重新安装 VisualStudio 2013 R3 {R3 的安装失败,因为它需要 Internet Explorer 版本 10,并且此计算机上已经安装了版本 11} 所以重新安装了 R4
卸载 AutoIt 并重新安装,选择 64 位库首选项。使用 x64 平台选项编译应用程序
卸载 …
我有一段从codeProject下载的代码.
该#if预处理指令似乎并没有工作就像我本来期望它的工作.
我没有在MyProject中定义DSHOWNET >>属性>>构建选项卡>>条件编译符号(对话框为空)
在下面的代码中,在构建项目时显示无法找到错误DShowNET.由于DSHOWNET从未被定义过,我对"使用DShowNET"的处理方式感到惊讶.
using System;
using System.Collections;
using System.Runtime.InteropServices;
#if DSHOWNET
using DShowNET;
using DShowNET.Device;
#else
#if VS2003
#else
using System.Runtime.InteropServices.ComTypes;
#endif
using DirectShowLib;
#endif
Run Code Online (Sandbox Code Playgroud)
#if预处理器指令是否在Visual Studio Express版本中有效?DSHOWNET是否需要明确"未定义"?还是我错过了其他一些基本概念?
我正在将一部分.NET应用程序移植到Linux上的Qt.我试图复制.NET函数的结果来创建密码+ salt的SHA-256哈希..NET代码是
return new SHA256Managed().ComputeHash(buffer);
Run Code Online (Sandbox Code Playgroud)
缓冲区是连接到密码的salt.
我考虑了几个crytopgraphic库,包括QCA和Botan,在阅读了几条评论后,我决定尝试Botan.但是,我没有在文档中找到正确的位置来执行上面列出的代码.
有人能指出我在精细手册中的位置或讨论使用Botan创建简单哈希的教程吗?我一直在谷歌搜索几个小时没有找到解决方案.管道和流有很多SHA-256哈希的例子,但我还没有找到简单哈希计算的例子.
我使用 Visual Studio C# Express 创建了可执行文件 MyService.exe。Express 版本中没有用于创建服务的选项。过去,这是使用 INSTSRV 和 SRVANY 手动安装为用户定义的服务,如MSDN 文章“如何创建用户定义的服务” 中所述
是否可以为此文件创建一个 wix 3.5 安装程序
我来自 C# 背景,仍然对 C++ 和 Qt 智能指针有所了解。这应该是一个基本问题:
在 myClass.h 中
QSharedPointer<AccessFlags> m_flags;
Run Code Online (Sandbox Code Playgroud)
在 myClass.cpp 我试图设置(设置正确的词?)m_flags 指针
if(m_flags.isNull())
m_flags = new AccessFlags();
class AccessFlags{
public:
QHash<QString,int> flags;
AccessFlags(); //The dictionary is setup in the constructor
};
Run Code Online (Sandbox Code Playgroud)
编译器抱怨“没有匹配 'operator=' in.. 如何设置指针?
由于我有 C# 背景,我有一些习惯需要改变。我试图从函数返回 QList<int> 。编译器错误消息是请求从“QList*”转换为非标量类型“QList”。这是函数:
QList<int> toCategories(QVariant qv)
{
QList<int>categories = new QList<int>();
if(qv.isValid() && qv.type() == QVariant::List)
{
foreach(QVariant category,qv.toList()){
categories.append(category.toInt() );
}
}
return categories;
}
Run Code Online (Sandbox Code Playgroud)
我很感激使用正确语法的文档或函数的链接
c++ ×6
qt ×6
c# ×3
.net ×1
automation ×1
botan ×1
cryptography ×1
data-binding ×1
dll ×1
instsrv ×1
json ×1
qcar-sdk ×1
qt-designer ×1
srvany ×1
web-services ×1
winforms ×1
wix ×1
xml ×1