在尝试熟悉c ++及其概念时,我遇到了
using namespace std
Run Code Online (Sandbox Code Playgroud)
和
#include <iostream>
Run Code Online (Sandbox Code Playgroud)
我的简单代码如下
#include "stdafx.h"
#include "ConsoleApplication5.h"
#include <iostream>
int main()
{
std::cout << "hi";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
使用使用intellisense的Visual Studio 2015社区显示
COUT
使用以下内容
std :: ostream std :: cout
作为一名C#程序员,这让我感到困惑.这是 :
的std :: ostream的
是一种回归类型
性病::法院
是传递的方法/参数或是
的std :: ostream的
依赖于
COUT
更新(Archimaredes答案后)
在C#中,可以使用以下内容:
StreamWriter srWrite;
Run Code Online (Sandbox Code Playgroud)
要么
StreamWriter srWrite = new StreamWriter(string filepath)
Run Code Online (Sandbox Code Playgroud)
或者可以使用:
StreamWriter srWrite = new StreamWriter(new NetworkStream(Socket.GetStream()));
Run Code Online (Sandbox Code Playgroud)
每种情况都是一种类型的对象
StreamWriter
Run Code Online (Sandbox Code Playgroud)
可以使用新对象或现有文件或网络流进行分配.
我之后尝试了同样的事情(原谅C#心态)std::ostream x = new std:ostream,返回一个没有默认的构造函数.
你能不能添加std :: ostream和std …
我无法从资源中检索正确的颜色值。
从 araks 的这个非常好的答案getResources().getColor()中,我们看到新的 Marshmallow API 已弃用旧方法,因此
我的实现:(尽管非常广泛地寻找原因)
int resColorID;
if (//something here) {
//some code
resColorID = R.color.color1;
//some code
resColorID = R.color.color2;
//some code
resColorID = R.color.color3;
}
int resC = ContextCompat.getColor(context, resColorID);
ColorDrawable cDraw = new ColorDrawable(resC);
Run Code Online (Sandbox Code Playgroud)
resC总是,但总是返回-1。对于我的一生,我找不到任何关于此的东西,
指定的颜色(它们是任意名称)R.color.color1等均在中定义colors.xml
额外信息:
为什么会发生这种情况?
美好的一天
我知道在这个问题上有各种各样的问题,我访问过很多问题,但他们没有提供任何"解决方案".
一般的答案是将语言级别设置为8(允许lambdas),就像我为使用年级构建的2个模块所做的那样,见下文
和
我想确认我已经安装了Java 8
java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
Run Code Online (Sandbox Code Playgroud)
设置语言级别时,它解决了它在IDE中的问题,但在构建我的项目以在我的设备上运行时,我将此作为错误:
Information:Gradle tasks [:app:assembleDebug]
/home/cybex/Documents/University/Year 5/Semester 2/WRAP302 - Advanced Programming 2/Assignments/Assignment1/Task1_SOS2/app/src/main/java/wrap302/nmu/task1_sos/SOSButton.java
Error:(15, 25) error: lambda expressions are not supported in -source 1.7
(use -source 8 or higher to enable lambda expressions)
/home/cybex/Documents/University/Year 5/Semester 2/WRAP302 - Advanced Programming 2/Assignments/Assignment1/Task1_SOS2/app/src/main/java/wrap302/nmu/task1_sos/MainActivity.java
Error:(85, 34) error: lambda expressions are not supported in -source 1.7
(use -source 8 or higher …Run Code Online (Sandbox Code Playgroud) 我需要创建一个带有圆角半透明角的QDialog 。问题是这样做时,角是半透明的,但以某种方式被窗口的 alpha 属性填充,使其变黑(这是我对问题原因的理解)
清晰可见的是圆形边缘,但有某种黑色的“背景”。QThread确认一下,此对话框是由from启动的模式对话框QMainWindow。它不是父窗口。
QDialog(根)组件的 CSS是:
QDialog {
background-color: rgba(250, 250, 250, 255);
border-radius: 30px;
color: #3C3C3C;
}
Run Code Online (Sandbox Code Playgroud)
组件布局如下所示
我也添加了阴影效果QDialog。这是构造函数代码QDialog:
UpdateDialog::UpdateDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::UpdateDialog)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(5);
this->setGraphicsEffect(effect);
}
Run Code Online (Sandbox Code Playgroud)
值得注意的是,父级QMainWindow在其构造函数中设置了以下属性
ui->setupUi(this);
statusBar()->hide();
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground, true);
// Set rounded corners style
setStyleSheet("QMainWindow {\n background-color:rgba(240,240,240,255);\n border-radius: 30px;\n}\n\nQDialog {\n border-radius: 30px;\n}");
// Add shadow to main window …Run Code Online (Sandbox Code Playgroud) I have an application that scans file and collects meta data about a file. One function is to get the file size of a file. To do so, I am using the winapi function GetFileSizeEx(Handle, PLARGE_INTEGER). The parameters require a file HANDLE and a reference to a PLARGE_INTEGER aka (*LARGE_INTEGER).
To get a file HANDLE in Qt, it is suggested here to get the file handle using QFile::handle() and pass the result into _get_osfhandle(int) and cast it …
大家好
我最近从Qt-Creator切换到NetBeans,对此决定感到遗憾,这是我遇到的有关编译器错误等的最新(许多)问题。
问题:
由于该std::to_string方法出现不合理的错误而安装了MinGW64编译器后,我遇到了类似的问题。
当前,我正在使用MinGW64编译器,并且在尝试使用该c_str()函数时,出现错误
无法解析标识符c_str
重新解析项目无效。尝试使用自动完成功能未提供任何建议
裸机最低代码:
#include <string>
using namespace std;
netm::netm(string hostname, int portNumber)
{
const char * c = hostname.c_str();
}
Run Code Online (Sandbox Code Playgroud)
Netbeans IDE信息:
Product Version: NetBeans IDE 8.2 (Build 201609300101)
Java: 1.8.0_112; Java HotSpot(TM) 64-Bit Server VM 25.112-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_112-b15
System: Windows 10 version 10.0 running on amd64; Cp1252; en_ZA (nb)
Run Code Online (Sandbox Code Playgroud)
有什么建议么?
注意:我是Play Framework的新手
使用此视频教程和播放列表,我设法创建一个简单的Web应用程序.
问题:
POST 路径文件中的方法似乎不执行所需的POST代码.
给定下面的路由文件,浏览localhost:{port}/user/register请求a GET,从而呈现并返回register view.
填写register view字段,然后单击submit,刷新页面(通过清除输入字段)并显示预期的"已注册"文本
如果method="post"已添加到form中register view,403 Forbidden page则会显示即时页面.
为什么不显示"注册"文本,我错过了什么(做错了)?
路线文件:
GET / controllers.HomeController.index
GET /user controllers.LoginController.index()
GET /user/login controllers.LoginController.login()
POST /user/login controllers.LoginController.doLogin()
GET /user/register controllers.LoginController.register()
POST /user/register controllers.LoginController.doRegister()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
Run Code Online (Sandbox Code Playgroud)
控制器:
HomeController
LoginController
Run Code Online (Sandbox Code Playgroud)
LoginController方法:
public Result index() { …Run Code Online (Sandbox Code Playgroud) 大家好
信息:
主题:组播
首先,我找到了解决方案,但我不明白为什么这是解决方案。
**范围:**(删除任何混乱/不必要的代码)
new_socket()
{
//SND_LOCAL_IP = 10.0.0.30 - local network adapter's IP
//SND_MCAST_PORT = 80 port used to broadcast Multicast Packets
//_SND_LOCAL_EP = new IPEndPoint(SND_LOCAL_IP, SND_MCAST_PORT); <problem>
_SND_LOCAL_EP = new IPEndPoint(SND_LOCAL_IP, 0); <fixed>
}
init_socket()
{
_SND_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
_SND_Socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(_SND_MCAST_IP, _SND_LOCAL_IP));
_SND_Socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true);
_SND_Socket.ExclusiveAddressUse = false;
_SND_Socket.Bind(_SND_LOCAL_EP); <<< ====== PROBLEM LINE=====
}
Run Code Online (Sandbox Code Playgroud)
问题:
我的侦听器在form_load事件上分别在线程上运行,因此它的初始化方式与我的SND_Socket相同,但是将SND_Socket.Bind()端口更改为0允许我接收这些多播数据包。
与def MSDN一样,添加ExclusiveAddress不能缓解此问题(因为接收和发送套接字以相同的方式初始化)。
如果套接字仅允许一个套接字绑定到特定端口,则为true;否则为true。否则为假。对于Windows Server 2003和Windows XP Service Pack 2,默认值为true;对于所有其他版本,默认值为false。
并在备注中进一步确认:
如果ExclusiveAddressUse为false,则多个套接字可以使用Bind方法绑定到特定端口。但是,只有一个套接字可以对发送到该端口的网络流量执行操作。如果有多个套接字尝试使用Bind(EndPoint)方法绑定到特定端口,则具有更特定IP地址的套接字将处理发送到该端口的网络流量。
如果ExclusiveAddressUse为true,则无论Internet协议(IP)地址如何,第一次使用Bind方法尝试绑定到特定端口都将成功;否则,将首次使用Bind方法绑定特定端口。在原始绑定套接字被销毁之前,所有随后使用Bind方法尝试绑定到该端口的操作都将失败。 …
大家好
背景:
我正在 debian 系统上构建和测试部署我的应用程序,但是我遇到了一些麻烦
正如文档页面所建议的那样,我的应用程序QOverload用于QNetworkReply。
一个示例用法是(来自文档页面):
connect(networkReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),
[=](QNetworkReply::NetworkError code){ /* ... */ });
Run Code Online (Sandbox Code Playgroud)
或在我的应用程序中发现的其他用法:
# header
QButtonGroup *grpProtocol;
QMetaObject::Connection conProtocol
# implementation
conProtocol = QObject::connect(ui->grpProtocol, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), [this](){
//do some action when a radio button in a QButtonGroup is toggled
});
Run Code Online (Sandbox Code Playgroud)
问题:
在调用make我的应用程序时,make抱怨一个错误:
mainwindow.cpp: In member function ‘void MainWindow::initConnectors()’:
mainwindow.cpp:462:53: error: ‘QOverload’ was not declared in this scope
conProtocol = QObject::connect(ui->grpProtocol, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), [this](){
^
mainwindow.cpp:462:79: …Run Code Online (Sandbox Code Playgroud) 我有一个复制一些文件的应用程序,但在复制过程中,最后修改的日期等更改为当前日期和时间。在一些论坛上,我看到建议使用MS 文档上指定的SETFILETIME调用。fileapi.h
然而,快速搜索显示这些函数在QFileDevice中可用,其中可以将setFileTime函数与以下FileTime枚举一起使用。注意,QFile或QFileInfo不允许修改这些日期和时间,只能读取这些日期和时间。
QFileDevice::FileAccessTime 0 最近访问文件(例如读取或写入)的时间。QFileDevice::FileBirthTime 1 创建文件的时间(UNIX 上可能不支持)。QFileDevice::FileMetadataChangeTime 2 文件元数据最后一次更改的时间。QFileDevice::FileModificationTime 3 最近修改文件的时间。
我怎样才能QFileDevice从一个QFileInfo对象甚至一个QFile对象(在这种情况下,QFile继承自QFileDevice- 例如 static_cast<>() 有帮助吗?
或者,我应该使用 Windows FileAPI.h- 我怎样才能从某些文件位置和QDateTime修改created时间来做到这一点lastModified?
我在通知中显示的图标遇到了麻烦。我浏览了材料设计页面中的图标和Notification doc。
我使用了BMP 256颜色格式的不同比例:360px,144px,48px,24px 16px都继续显示白色块。
我将格式更改为PNG,使用了144px(在代码中使用的名称为“ ic_notify_icon”),仍然没有运气。
//Global
private NotificationManager mNotifyManager ;
private Notification mNotify;
private void initialize() {
mNotifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder mNotificationBuilder = new Notification.Builder(this);
mNotificationBuilder.setSmallIcon(R.mipmap.ic_notify_icon);
mNotificationBuilder.setContentTitle("A Title here");
mNotificationBuilder.setContentText("Some content text here");
mNotify = mNotificationBuilder.build();
ShowNotify();
}
private void ShowNotify(){
//...some code here
mNotifyMan.notify(0, mNotify);
//...some code here
}
Run Code Online (Sandbox Code Playgroud)
有什么建议么?
附言:我看了这篇文章,同样的问题,但我觉得它没有帮助/用处,或者我只是不理解要求...
我正在尝试pthread示例.这是我的代码:
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
void*AsalK1(void *gelen);
int main(){
int *i;
i= new int;
*i=1;
int sonSayi;
pthread_t th1, th2, th3, th4;
printf("---------------------------------------------\n");
printf("| Threadler ile Asal Sayi Bulma |\n");
printf("---------------------------------------------\n");
printf("Son sayi degeri: 1000000 \n");
int r1=pthread_create( &th1, NULL, AsalK1, (void *)i);
*i=3;
int r2=pthread_create( &th2, NULL, AsalK1, (void *)i);
*i=5;
int r3=pthread_create( &th3, NULL, AsalK1, (void *)i);
*i=7;
int r4=pthread_create( &th4, NULL, AsalK1, (void *)i);
pthread_join( th1, NULL);
pthread_join( th2, NULL);
pthread_join( th3, NULL);
pthread_join( th4, NULL);
return 0; …Run Code Online (Sandbox Code Playgroud) 我有一个名为的自定义结构StorageFile,其中包含有关存储在数据库中的文件的一些信息。
class StorageFile : public QObject {
Q_OBJECT
public:
int ID = -1;
QString filename;
QString relativeLocation;
MediaType type;
QDateTime dateLastChanged;
quint64 size;
QString sha256;
//...
explicit StorageFile(QObject* parent = nullptr);
StorageFile(const StorageFile& other);
StorageFile& operator= (const StorageFile& other);
bool operator< (const StorageFile& storageFile); < --------- implemented operator
bool operator== (const StorageFile& storageFile);
//...
}
Run Code Online (Sandbox Code Playgroud)
我将这些 StorageFile 对象添加到QMap,并且QMap 需要实施operator< - 我有。编译器给出以下错误:
F:\Qt\Qt5.13.1\5.13.1\mingw73_32\include\QtCore/qmap.h:71:17: error: no match for 'operator<' (operand types are 'const StorageFile' and …Run Code Online (Sandbox Code Playgroud)