我有一个SQLite-Database,我把它做成了一个QSqlTableModel
.为了显示数据库,我将该模型放入了QTableView
.
现在我想创建一个方法,将选定的行(或整行)复制到QClipboard
.之后我想将它插入我的OpenOffice.Calc-Document.
但我不知道如何处理Selected
SIGNAL QModelIndex
以及如何将其放入剪贴板.
我想用a map
来存储键值对.
地图的关键字应包含有关int
一个点的坐标()的信息.
一种可能性是将int
s 转换为string
.例如,坐标(x,y)可以表示为"x#y"
并将此字符串存储"x#y"
为键.
另一种可能性是使用一对来存储坐标pair<int, int>
并将其pair
用作关键.
哪种方式更好,为什么?
考虑(1):
uint8_t *pUART = reinterpret_cast<uint8_t*>(0x0800);
Run Code Online (Sandbox Code Playgroud)
我知道(1)只需将pUART指针更改为0x0800,但我很困惑这种方法是如何工作的.
如果是(2)那将是有意义的:
uint8_t* pUART = reinterpret_cast<uint8_t*>(0x0800);
Run Code Online (Sandbox Code Playgroud)
我感到困惑,因为(1)与(3)相同:
uint8_t x = reinterpret_cast<uint8_t*>(0x0800);
Run Code Online (Sandbox Code Playgroud)
但编译器不接受这个.有人可以为我清除这个吗?为什么(1)工作但不工作(3).
我需要将另一对带有给定尾随模式的字符串推回/附加到 C 中的现有字符数组。为此,我愿意使用“sprintf”,如下所示。
#include <stdio.h>
#include<string.h>
int main()
{
char my_str[1024]; // fixed length checked
char *s1 = "abcd", *s2 = "pqrs";
sprintf(my_str, "Hello World"); // begin part added
sprintf(my_str, "%s , push back '%s' and '%s'.", my_str, s1, s2); // adding more to end of "my_str" (with given trailling format)
/* here we always use 'my_str' as the first for the string format in sprintf - format starts with it */
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我遵循这种方法时,我收到“内存重叠”警告。这是一个严重的问题吗?(如内存泄漏、错误输出等)
public class fakultaet1 {
public static long fakultaet(long n) {
if (n<0)
throw new FakultaetNichtDefiniertException(n);
if (n==0)
return 1;
long fakultaet = 1;
while(n>1){
fakultaet *= n; // had a litte mistake here
n--;
}
return fakultaet;
}
public class FakultaetNichtDefiniertException extends RuntimeException{
public FakultaetNichtDefiniertException(long n){
super("Die Fakultät is für den Wert "+ n +" nicht definiert.");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(fakultaet(5));
}
}
Run Code Online (Sandbox Code Playgroud)
所以我希望我的代码计算输入n的阶乘,并且它应该在数字小于0时抛出异常,但如果我尝试运行它给我这个输出.
Exception in thread "main" java.lang.Error: Unresolved …
Run Code Online (Sandbox Code Playgroud) 我想在c ++中做这样的事情
If x is equal to either a or b or c
and y is equal to either d or e or f
and z is equal to either g or h or i, it would turn true and execute the code
Run Code Online (Sandbox Code Playgroud)
我有点迷失了
if(x==a||x==b||x==c && y==d||y==e||y==f && z==g||z==h||z==i){
// Do x
}
Run Code Online (Sandbox Code Playgroud) c++ ×4
c ×2
clipboard ×1
exception ×1
if-statement ×1
java ×1
pointers ×1
qt ×1
qt4 ×1
qtableview ×1