我有一个简单的表单UI,有一个按钮插槽,启动一个线程:
void MainWindow::LoadImage()
{
aThread->run();
}
Run Code Online (Sandbox Code Playgroud)
run()方法如下所示:
void CameraThread::run()
{
qDebug("Staring Thread");
while(1)
{
qDebug("ping");
QThread::sleep(1);
}
}
Run Code Online (Sandbox Code Playgroud)
当我单击调用LoadImage()的按钮时,UI变得无法响应.我定期看到"ping"消息作为调试输出,但UI挂起,不响应任何事情.为什么我的线程没有单独运行?CameraThread派生为公共QThread我使用gcc版本4.4.3(Ubuntu 4.4.3-4ubuntu5)与QT库和QT Creator来自Ubuntu 10.04(x86)存储库.
在我的活动中,我在surfaceView上显示相机预览.它在Nexus One和HTC Desire上完美运行,但在三星Galaxy SI上看到奇怪的线条,奇怪的比例和所有三次.请参阅下面的截图.
问题似乎与此类似: Android上的相机预览 - 1.5版本的sdk上的奇怪行, 但没有任何评论有帮助.我试图交换相机参数的高度,宽度,但差别不大.
(旁注:我的活动始终处于横向模式,已修复.我在清单中将其修复为screenOrientation参数,以防万一).
我的SurfaceHolderCallback的代码(我活动中的相关内部类):
class SurfaceHolderCallback implements SurfaceHolder.Callback {
private static final int IMAGE_WIDTH = 512;
private static final int IMAGE_HEIGHT = 384;
private static final String ORIENTATION = "orientation";
private static final String ROTATION = "rotation";
private static final String PORTRAIT = "portrait";
private static final String LANDSCAPE = "landscape";
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
//Surface.setOrientation(Display.DEFAULT_DISPLAY,Surface.ROTATION_90);
Parameters p = camera.getParameters();
p.setPictureSize(IMAGE_WIDTH, IMAGE_HEIGHT);
p.set(ORIENTATION, PORTRAIT);
p.set(ROTATION, 90);
// p.setPreviewSize(640, 480); …Run Code Online (Sandbox Code Playgroud) 我有一个从ListActivity派生的Contact Activity,它显示了联系人列表,点击了item,初始化了一个从ListActivity派生的新的Activity Message Activity.
现在我知道,我可以在Bundle中打包一些信息并在创建活动之前传递它,但有没有办法在"MessageActivity"的onCreate方法中获取"ContactActivity"的实例?
我使用grep递归来搜索文件中的字符串,所有匹配的文件和包含该字符串的行都在终端上打印.但是有可能获得这些线的行号吗?
例如:目前我得到的是/var/www/file.php: $options = "this.target",但我想要得到的是/var/www/file.php: 1142 $options = "this.target";,1142包含该字符串的行号在哪里.
我用来递归grep的语法是 sudo grep -r 'pattern' '/var/www/file.php'
还有一个问题是,我们如何得到不等于模式的结果.像所有文件一样,但不是那些有特定字符串的文件?
我需要制作4个叉子1000次.我写了这个,但它永远运行:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#define N 512
void chunk0(void);
void chunk1(void);
void chunk2(void);
void chunk3(void);
double get_time(void);
void main(void)
{
int i,j,k,iterations=0;
unsigned int *a=(unsigned int *)malloc(N*N*(sizeof(unsigned int)));
unsigned int *b=(unsigned int *)malloc(N*N*(sizeof(unsigned int)));
unsigned int *c=(unsigned int *)malloc(N*N*(sizeof(unsigned int)));
pid_t pid;
for(iterations=0;iterations<1000;iterations++){
srand ( time(NULL) );
double start=get_time();
pid = fork();
if (pid == 0) {
chunk0();
}else {
pid = fork();
if (pid == 0){
chunk1();
}else {
pid = fork();
if (pid …Run Code Online (Sandbox Code Playgroud) 我有去的,取代了"无效"字符(由我正则表达式定义)与blankspace的应用程序.我想要它,以便如果文件名中有2个或更多空格,则修剪一个.例如:
Deal A & B.txt在我的应用程序运行后,将重命名为Deal A B.txt(3个空格b/w A和B).我想要的是这样的:( Deal A B.txtA和B之间的一个空格).
我试图确定如何做到这一点 - 我想我的应用程序将通过所有的文件名至少运行一次,以取代无效字符,然后通过文件名再次运行甩掉多余的空白.
任何人都可以帮我吗?
这是我目前用于替换无效字符的代码:
public partial class CleanNames : Form
{
public CleanNames()
{
InitializeComponent();
}
public void Sanitizer(List<string> paths)
{
string regPattern = (@"[~#&$!%+{}]+");
string replacement = " ";
Regex regExPattern = new Regex(regPattern);
StreamWriter errors = new StreamWriter(@"S:\Testing\Errors.txt", true);
var filesCount = new Dictionary<string, int>();
dataGridView1.Rows.Clear();
try
{
foreach (string files2 in paths)
{
string filenameOnly = System.IO.Path.GetFileName(files2);
string pathOnly = System.IO.Path.GetDirectoryName(files2); …Run Code Online (Sandbox Code Playgroud) 在这里我询问如何识别计数器\subsection和\theorem.
得到的外观是相同的(除了数学专用东西,如一个定理中的内容被放在重点)如果只存在是为了防止换行符\后款的方式.
有没有办法做到这一点?谢谢.
正如提到这个主题,在Visual Studio 2008的安装程序有时会静静地失败创建Include并Lib在被创建,都应该目录C:\Program Files\Microsoft SDKs\Windows\v6.0A\。
有没有人知道安装程序的修补程序,或者让安装成功的可靠方法?我正在安装 VS2005 和 VS2010 的 Win7/64 机器上安装。卸载并重新安装 VS2008 本身不起作用,创建后修复安装也不起作用。我可以避免擦拭机器并重新开始吗?
我是Android NDK的新手,我不了解静态库和共享库之间的区别.它们是什么,何时我会选择一种类型而不是另一种?
我试图使用httpwebrequest在远程服务器上使用类似服务的休息,并且从第一次执行本身开始,我的代码挂起了程序.然后我尝试将它作为控制台应用程序,以确保它与程序本身无关,但没有运气!
string credentialsJson = @"{""username"":""test"",
""password"":""test""
}";
int tmp = ServicePointManager.DefaultConnectionLimit;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://qrua.com/qr/service" + @"/auth/login");
request.Method = "POST";
request.KeepAlive = true;
request.Timeout = 50000 ;
request.CookieContainer = new CookieContainer();
request.ContentType = "application/json";
try
{
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(credentialsJson);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION:" + e.Message);
}
//WebResponse response = request.GetResponse();
try
{
using (WebResponse response = (HttpWebResponse)request.GetResponse())
{
Console.WriteLine("request:\n" + request.ToString() + "\nresponse:\n" + response.ContentLength);
response.Close();
}
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION: in sending …Run Code Online (Sandbox Code Playgroud) android ×3
c# ×2
android-ndk ×1
c ×1
c++ ×1
camera ×1
fork ×1
getresponse ×1
grep ×1
latex ×1
line ×1
qt ×1
qthread ×1
regex ×1
webrequest ×1