小编p.i*_*.g.的帖子

Qt - 小部件 - 更新

我有一个带按钮的小部件.我想,每按一下按钮,就会在小部件中添加一个标签.我给出了下面的代码,但是没有用.我不知道为什么.来人帮帮我?

class EditThingsWindow:public QWidget
{
    Q_OBJECT

    QPushButton * add;

public:
    EditThingsWindow();

public slots:
    void addButtonClicked();
};

EditThingsWindow::EditThingsWindow():QWidget()
{
    QWidget* wid = this;
    wid->resize(400,400);

    add=new QPushButton(wid);
    add->setText("Add");
    add->move(20,10);
    line=new QLineEdit(wid);
    line->move(30,50);

    QObject::connect(add,SIGNAL(clicked()),this,SLOT(addButtonClicked()));
}

void EditThingsWindow::addButtonClicked()
{
    QLabel* label = new QLabel(this);
    label->move(200,160);
    label->setText(";;;;;;;;;;;;;;");
 }
Run Code Online (Sandbox Code Playgroud)

c++ user-interface qt

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

将多行QString转换为单行QString

我有这样的事情:

void ReadFileAndConvert ()
{
    QFile File (Directory + "/here/we/go");

    if(File.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QTextStream Stream (&File);
        QString Text;

        do
        {
            Text = Stream.readLine();
            Text = Text.simplified();
            // Here I want to convert the multiline QString Text into a oneline QString

// ...
}
Run Code Online (Sandbox Code Playgroud)

QString Text包含一个多行文本,我需要将其转换为在线Text/QString.我怎样才能做到这一点?问候

c++ qstring qt

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

如何为 QGraphicsSimpleTextItem (Qt C++) 设置背景?

我已经添加到我的QGraphicsScenea QGraphicsSimpleTextItem,但只有一个简单的文本是当前背景不可读的。因此我想设置 的背景颜色QGraphicsSimpleTextItem,但是......没有这样的方法。最简单的解决方案是什么?

c++ user-interface qt

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

c ++矢量冒泡排序

我使用g ++ -std = c ++ 11 Sort.cpp来编译我的文件.

我的问题是冒泡排序不排序.

也许我按值传递矢量,但我不知道我的第一次尝试使用c ++,我选择使用矢量库.

我的代码是:

#include <iostream>
#include <vector>

using namespace std;

void bubbleSort(vector<int> a);

void printVector(vector<int> a);

int main(int argc, char const *argv[])
{
    vector<int> a{3,2,6,1};
    printVector(a);

    bubbleSort(a);
    printVector(a);
}

void bubbleSort(vector<int> a)
{
    bool swapp = true;
    while(swapp)
    {
        swapp = false;
        for (int i = 0; i < a.size()-1; i++)
        {
            if (a[i]>a[i+1] )
            {
                a[i] += a[i+1];
                a[i+1] = a[i] - a[i+1];
                a[i] -=a[i+1];
                swapp = true;
            }
        } …
Run Code Online (Sandbox Code Playgroud)

c++ vector bubble-sort c++11

1
推荐指数
1
解决办法
2万
查看次数

Qt C++ - 不允许使用QList <float**>类型

我想将一个float**参数列表传递给一些float**只使用C-syle的方法(但我们认为我们可以使用QList<>as参数类型).

我试过了

QList< float** > list_ = new QList< float** >();
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我应该用什么呢?对于二维矩阵列表,Qt容器会是什么?

谢谢

c++ arrays qt types list

0
推荐指数
1
解决办法
524
查看次数

如何继承QVector?

我有一个名为Symbol的类,我想创建一个QVector子类(Symbols)来添加一些有用的方法.但是当我使用来自另一个类A的符号时,编译器会给出错误'符号没有命名类型'.

class Symbols: public QVector< Symbol >
{
public:
    Symbols() {}

    // Useful methods
    QSymbol findSymbol(const QString &name);

    // ...
};

class A
{
private:
    Symbols symbols;
};
Run Code Online (Sandbox Code Playgroud)

它是否正确分类?

为什么在编译A类时出现'符号不命名类型'?

c++ qt qvector qtcore

-1
推荐指数
1
解决办法
1036
查看次数

无法使用Vector编码显示名称

下午好.....我目前是C++课程的学生,我们正在编写Vector代码.在作业中,我们必须显示3个学生姓名.当我在运行以下代码后添加名称时,它只显示向量的数量而不是名称(根据需要).任何帮助表示赞赏.

#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>

using std::cout;
using std::cin;
using namespace std;

int main()
{
    bool running = true;
    char choice;
    vector <string> studentVector;
    cout << "My Student Vector" << endl;
    while (running == true)
    {
        cout << "Choose a Selection: [A]dd Student, [V]iew Student, [R]emove      Student, [E]xit" << endl;
        cin >> choice;
        cin.ignore();

        if (choice == 'A' || choice == 'a')
        {
            cout << "Enter Student's Name: ";
            string tempVar;
            getline(cin, tempVar);

            studentVector.push_back(tempVar);
        }
        else …
Run Code Online (Sandbox Code Playgroud)

c++ vector c++11

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

如何向后打印数组

用户输入一个放置在数组中的数字,然后需要对该数组进行排序backwadrds

int main()
{
    int numbers[5];
    int x;

    for (int i = 0; i<5; i++)
    {
        cout << "Enter a number: ";
        cin >> x;
        numbers[x];
    }

    for (int i = 5; i>0 ; i--)
    {
        cout << numbers[i];
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ arrays

-6
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×8

qt ×5

arrays ×2

c++11 ×2

user-interface ×2

vector ×2

bubble-sort ×1

list ×1

qstring ×1

qtcore ×1

qvector ×1

types ×1