有没有办法在ListView中的某个事件上隐藏特定项?
到目前为止,我可以通过设置做到这一点visible,以false和height为代表的零.
但是,如果我将listView中的间距设置为2,例如,此解决方案似乎已被破坏.
我有一个外部变量和一个数组声明的问题.如何使用不在可声明文件中的全局变量声明数组.
file1.cpp
const int size = 10;
Run Code Online (Sandbox Code Playgroud)
mainfile.cpp
extern const int size;
void main()
{
int mas[size];
}
Run Code Online (Sandbox Code Playgroud)
int mas[size];
Run Code Online (Sandbox Code Playgroud)
这条线有一个问题.请猜猜想?
有人知道如何删除此间距吗?
下面的那些线会减少它们,但不能完全消除。
margins.top: 0
margins.bottom: 0
margins.left: 0
margins.right: 0
Run Code Online (Sandbox Code Playgroud)
更新 我添加了一些代码。也许这可以帮助确定我的问题。最初,箭头所在的空格用于图例和刻度值。我在不更改源代码的情况下无法执行任何操作。
ScopeView.qml
import QtQuick 2.0
import QtCharts 2.1
ChartView {
id: chartView
animationOptions: ChartView.NoAnimation
theme: ChartView.ChartThemeQt
legend.visible: false
margins.top: 0
margins.bottom: 0
margins.left: 0
margins.right: 0
backgroundRoundness: 0
property bool openGL: true
onOpenGLChanged: {
series("signal 1").useOpenGL = openGL;
}
ValueAxis {
id: axisY1
min: -1
max: 4
labelsVisible: false
tickCount: 3
color: "transparent"
}
ValueAxis {
id: axisX
min: 0
max: 1024
labelsVisible: false
tickCount: 4
color: "transparent"
} …Run Code Online (Sandbox Code Playgroud) 我创建了一个有两个目标的项目,core.dll并且runner.exe.
Core.dll依赖于取决于Qt5::Core。
Runner.exe依赖于取决于core.dll。
我还创建了柯南食谱conanfile.py。
我定义qt在requirements:
def requirements(self):
self.requires("qt/e5.12.4@mikhail/testing", private=False)
Run Code Online (Sandbox Code Playgroud)
在package_info我使用components:
def package_info(self):
self.cpp_info.components["core"].libs = ["core"]
self.cpp_info.components["core"].requires = ["qt"]
self.cpp_info.components["runner"].requires = ["core"]
Run Code Online (Sandbox Code Playgroud)
在构建时我有错误:
文件“C:\Users\user\AppData\Roaming\Python\Python37\site-packages\conans\client\installer.py”,第 571 行,在 _call_package_info 中引发 ConanException(“%s package_info(): %s” % ( str(conanfile), e)) conans.errors.ConanException: lexer/1.0.0@mikhail/testing package_info():软件包要求“qt”未在组件要求中使用
我想我错过了一些细节。如果有任何建议或参考资料,我将不胜感激。
柯南文件.py
from conans import ConanFile, CMake, tools
import os.path
class LexerConan(ConanFile):
name = "lexer"
license = "Proprietary"
author = "Mikhail"
topics = …Run Code Online (Sandbox Code Playgroud) 为什么我不能使用new [ ]smart_pointers?
其实我无法理解这段文字.
警告您应该将auto_prt或shared_ptr对象仅用于new分配的内存,而不是new []分配的内存.您不应该将auto_ptr,shared_ptr或orunique_ptr用于未通过new分配的内存,或者在unique_ptr的情况下,通过new或new []使用.
最后我安装了Ubuntu并设置了Qt + Valgrind来防止内存泄漏,这是我在Windows中无法做到的.所以我无法理解这段代码是否提供内存泄漏?事实上,Valgrind说我只有500多个问题,但没有泄漏.一世
#include <QWidget>
#include <QFrame>
#include <QVBoxLayout>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget * wdgt = new QWidget; //this line should be the cause of leakage
//if it exist (as far as i know)
QVBoxLayout *layout = new QVBoxLayout;
QFrame * frame = new QFrame;
frame->setFrameStyle(QFrame::Panel | QFrame::Plain);
frame->setLineWidth(5);
layout->addWidget(frame);
wdgt->setLayout(layout);
wdgt->setFixedSize(800,600);
wdgt->show();
return a.exec();
}
Run Code Online (Sandbox Code Playgroud) 我已经部署了5.10 32位msvc programm.exe,它在Windows 8.1上运行正常.但我必须在XP上运行它,我不能这样做.它说" progamm.exe is not a valid Win32 app".我注定了吗?我是否必须使用支持XP的Qt的最新版本,如Qt5.6?谢谢!
我跑了一些代码
template<class InputIt, class T>
constexpr // since C++20
T accumulate(InputIt first, InputIt last, T init)
{
for (; first != last; ++first) {
init = std::move(init) + *first; // std::move since C++20
}
return init;
}
Run Code Online (Sandbox Code Playgroud)
我有个问题。为什么我们必须使用 std::move oninit即使init是int?
我有一个问题,它不想使用static_cast <>进行强制转换.它能是什么?
void myCompare(const void *str)
{
const char *ca = *(static_cast<const char**>(str)); //error
const char *a = *(const char **)str; //ok
}
Run Code Online (Sandbox Code Playgroud) QItemDelegate如何进行如附图所示的定制。这是一个QTreeView。我要自定义并添加的最后一个元素QItemDelegate 
现在我只有绿separator线,想在QCheckBox分隔符下方添加一条。如何实施这种行为?
void SeparatorItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
if (index.data(Qt::UserRole + 1).toString() == tr("Unsorted"))
{
QPen pen(Qt::green, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
painter->drawLine(option.rect.left(), option.rect.center().y(), option.rect.right(), option.rect.center().y());
}
else
{
QItemDelegate::paint(painter, option, index);
}
}
QSize SeparatorItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
if (index.data(Qt::UserRole + 1).toString() == tr("Unsorted"))
{
return QSize(200, 25);
}
return QItemDelegate::sizeHint(option, index);
}
void SeparatorItemDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) …Run Code Online (Sandbox Code Playgroud) 当我的应用程序被销毁时,我想终止(完成)QThread.因此,我调用terminate()和quit()内destructor从'我的QThread的派生类.安全吗?
class Session : public QThread
{
Q_OBJECT
private:
CheckerAdapter *inst;
public:
explicit Session(CheckerAdapter *inst, QObject *parent = 0);
void run();
~Session(){
terminate();
quit();
}
};
Run Code Online (Sandbox Code Playgroud) 我有一些声明
vector<double> ved1(10), ved2(10), ved3(10);
array<double, 10> vod1, vod2, vod3;
valarray<double> vad1(10), vad2(10), vad3(10);
Run Code Online (Sandbox Code Playgroud)
如何从此版本转换代码
vad3 = 10.0* ((vad1 + vad2) / 2.0 + vad1 * cos(vad2));
Run Code Online (Sandbox Code Playgroud)
对此
transform(ved1.begin(), ved1.end(), ved2.begin(), ved3.begin(), plus<double>());
Run Code Online (Sandbox Code Playgroud)
仅使用vector-STL版本.