我正在使用Qt拍摄截图(丝网印刷).
QPixmap::grabWindow(QApplication::desktop()->winId());
Run Code Online (Sandbox Code Playgroud)
我希望应用程序在后台启动,即我希望它在启动时隐藏(甚至在控制台模式下运行).
我怎么能在Qt中这样做?
我有两个小部件mainwindow123和二等.在我的MainWidget.cpp中有一个lineedit和button字段.最初我可以将焦点设置在行编辑上.但是在来自second.cpp Widget后,我无法将注意力集中在lineedit上.请帮帮我..哪个地方我犯了错误?提前致谢.
这是我的代码MainWidget.cpp
MainWidget::MainWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainWidget)
{
ui->setupUi(this);
s = new second();
connect(ui->pushButton, SIGNAL(clicked()),this,SLOT(callSecond()));
}
MainWidget::~MainWidget()
{
delete ui;
}
void MainWidget::callSecond()
{
s->show();
}
Run Code Online (Sandbox Code Playgroud)
second.cpp
second::second(QWidget *parent) :
QWidget(parent)
{
QPushButton *first = new QPushButton("first");
first->setStyleSheet(
"background-color:black;"
);
QGridLayout *d = new QGridLayout();
d->addWidget(frist,0,0,1,1);
setLayout(d);
connect(first,SIGNAL(clicked()),this,SLOT(first()));
}
void second:: first()
{
this->hide();
}
Run Code Online (Sandbox Code Playgroud) 我需要动画小部件透明度.在我看来,我应该使用QPropertyAnimation.但我怎么能定义小部件半透明?我应该使用一些像这样的?
我试图使用Qt的qtconcurrentmap来处理一些图像,我收到以下错误
argument of type 'void (ClassName::)(QString&)' does not match 'void (ClassName::*)(QString&)
Run Code Online (Sandbox Code Playgroud)
我也来了
/Library/Frameworks/QtCore.framework/Headers/qtconcurrentmapkernel.h::
In member function 'bool QtConcurrent::MapKernel<Iterator, MapFunctor>::runIteration(Iterator, int, void*)
[with Iterator = QList<QString>::iterator, MapFunctor = void (ClassName::*)(QString&)]':
/Library/Frameworks/QtCore.framework/Headers/qtconcurrentmapkernel.h:73:
error: must use '.*' or '->*' to call pointer-to-member function in
'((QtConcurrent::MapKernel<QList<QString>::iterator, void (ClassName::*)(QString&)>*)this)->QtConcurrent::MapKernel<QList<QString>::iterator, void (ClassName::*)(QString&)>::map (...)'
Run Code Online (Sandbox Code Playgroud)
这是我的代码
void ClassName::processImage(QString &f)
{
Image image;
image.read(qPrintable(f));
try {
//Apply effects on an Image
} catch ( Magick::Exception & error) {
// Displaying any possible errors on the text browser …Run Code Online (Sandbox Code Playgroud) 我正在编写一个基于QWizard Qt对象的向导UI.在某种特殊情况下,我希望用户使用主机,用户名和密码登录服务.然后,向导的其余部分操纵此服务以执行各种设置任务.登录可能需要一段时间,尤其是在DNS名称需要很长时间才能解决的错误情况下 - 或者甚至可能根本无法解决.
所以我的想法是使用registerField机制强制所有三个字段,当用户点击Next时,我们在向导页面上显示一个小小的悸动,说"连接到服务器,请稍候......",同时我们尝试连接到背景.如果连接成功,我们将进入下一页.如果没有,我们会突出显示有问题的字段并要求用户重试.
但是,我对如何实现这一点感到茫然.我想到的选项:
1)覆盖validatePage并让它在后台启动一个线程.在validatePage()内输入一个等待,它将Qt事件循环泵出,直到线程结束.你认为这是最丑陋的解决方案,但......
2)隐藏真正的下一个按钮并添加一个自定义的下一个按钮,当单击该按钮时,在一个线程中调度我的长时间运行功能,并等待一个"验证完成"信号被某些东西引发.当发生这种情况时,我们手动调用QWizard :: next()(我们完全绕过了validatePage和朋友的真实验证逻辑.)这甚至更加丑陋,但将丑陋移到了可能使开发更容易的不同层次.
当然有更好的方法吗?
诺基亚Qt的基本概念是什么?
在进入诺基亚Qt框架之前,我想知道些什么?
任何人都可以帮助我吗?
诺基亚Qt我是新手.提前致谢.
我正在为应用程序创建自定义消息框.我的对象派生自QMessageBox,但我重写了paintEvent()方法以更改其外观.奇怪的是,虽然我没有在派生方法中调用基础paintEvent方法,但默认情况下我的自定义消息框仍然用OK按钮绘制.这是我的代码:
class MessageWidget : public QMessageBox
{
Q_OBJECT
public:
MessageWidget(QWidget* parent = 0);
~MessageWidget();
void setTitle(const QString& title);
const QString& title() const;
protected:
void paintEvent(QPaintEvent* event);
}
MessageWidget::MessageWidget(QWidget* parent) :
QMessageBox(parent)
{
setWindowFlags(Qt::FramelessWindowHint);
setAutoFillBackground(true);
}
void MessageWidget::paintEvent(QPaintEvent* /*event*/)
{
QPainter painter(this);
QRect boxRect = rect();
QPainterPath path;
path.addRoundedRect(boxRect, 15, 15);
painter.fillPath(path, palette().window());
painter.drawPath(path);
QRect titleRect = boxRect;
int titleHeight = fontMetrics().height();
titleRect.moveBottom(titleHeight);
boxRect.moveTop(titleRect.bottom());
painter.drawLine(titleRect.bottomLeft(), titleRect.bottomRight());
painter.drawText(titleRect, Qt::AlignLeft, "Some Text");
}
当我没有调用基础paintEvent方法时,如何绘制其他东西?
鉴于声明
class DBuffer
{
//...
};
typedef QList<DBuffer*> DBuffers;
QList<int> fds;
QMap<int, DBuffers> buffers;
Run Code Online (Sandbox Code Playgroud)
下面给出的函数中的代码行是什么意思.
function()
{
// what does this line mean? what is "&bufs"
DBuffers &bufs=buffers[fds[i]];
}
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我创建了两个主窗口,我想从mainwindow1(运行中)调用mainwindow2.在mainwindow1我已经使用app.exec_()(PyQt)并显示maindow2我在按钮的click事件中使用maindow2.show()但没有显示任何内容
我这几天正在学习QT,我想测试do while循环,实际登录正常工作,但在QT中应用程序冻结..我已经定义了randnum并在头文件中猜测(公共)
void MainWindow::on_pushButton_clicked()
{
srand (time(NULL));
randnum = rand() % 10 +1;
do {
guess = ui->spinBox->value();
if (guess < randnum)
{
ui->label->setText("try something big");
}
else if (guess > randnum)
{
ui->label->setText("try something small");
}
else
ui->label->setText("YAY?");
} while (guess != randnum);
}
Run Code Online (Sandbox Code Playgroud)
请告诉我如何找到冻结的原因..谢谢!