问题标签 [qt5.2]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - changing image's size to fit the new size of the GUI window
I've read the documentation of Qt for resizing policy but I couldn't find how can I achieve the scenario of changing the image's size to fit the new size of Qlabel.
This is my GUI structure
Now I have cv::Mat
image. I have converted to QPixmap
.
This is the button
I want to resize the image's size every time the user changes the size of the window. If I expand the window, the image also is expanded but the problem if I shrink the window, the size of the window is restricted to the size of the image. Any suggestions
c++ - Qt QNetworkAccessManager 异常
QNetworkAccessManager
我对Qt 类有一些奇怪的行为。基本上每当我这样做时:
我得到:
0x75a1c41f 异常,代码:0x6a6:RPC 服务器无效,标志=0x1(无法继续执行)(第一次机会)
当调试器到达包含new QNetworkAccessManager();
. 我在主窗体中进行测试,所以没有线程运行,没有什么可能导致内存中断或类似的事情。我正在使用带有 mscv2012 编译器的 Qt 5.2.0。我认为这个错误会导致我在服务器响应中得到一些垃圾,如下所示:
有人可以帮忙吗!
qt - Qt 控件边距的奇怪行为
我刚刚开始使用 Qt (5.3) 并遇到了一些控件出现的边距我无法控制的事实。
首先,我尝试将 QLabel 和 QPushButton 放在 QMainWindow
在这种情况下,标签在顶部出现 12 像素的边距(见图)。QPushButton 以 1 像素的顶部和左侧边距出现。但是如果我插入带有边框的 QFrame,它就会出现没有任何边距。
所以边距似乎是 QLabel 和 QPushButton 的属性。但:
当我尝试在窗口和控件之间添加额外的 QFrame 时:
我得到了不同的图片: QLabels 上边距缩短到 1 像素 QPushButton 1 像素边距保持不变,但按钮的高度已经改变
我试过: setStyleSheet( "padding:0px" ) 和 setContentsMargins( 0, 0, 0, 0 )
对于所有元素,但没有任何成功。
任何帮助将不胜感激
c++ - 如何在 ubuntu sdk 中将按钮连接到 FileDialog 函数?
我刚刚开始在 Ubuntu 14.10 上使用基于 Qt5.2.1 的 QtCreator 3.1.1 为 Ubuntu 部署我的第一个应用程序。我需要打开一些视频文件,所以我要放置一个按钮来选择文件。我也知道我可以使用此功能打开文件:
这是我的问题:如何将它们相互连接?我希望在单击按钮时打开 FielDialog。这是唯一的方法吗?我的意思是我不能在 C++ 代码中做同样的过程吗?
qt - QFileSystemWatcher locks directory on Windows
I am watching a directory recursively using QFileSystemWatcher. And I am not able to rename/delete the parent directory either programmatically or manually if its sub directories are being watched.
When trying to rename manually through system i get a message box saying "The action cannot be completed because the folder/ file in it is opened in another program" and on renaming programmatically it fails.
I got these similar bugs, but no resolution:
http://qt-project.org/forums/viewthread/10530
https://bugreports.qt-project.org/browse/QTBUG-7905
I am not watching . and .. as said in the above link, but still the directory is locked.
In case of programmatically renaming.. I tried a workaround: 1. Remove all the subdirectory paths from watcher before renaming the parent. 2. Rename parent. 3. Add subdirectory paths again.
But here too my program fails on first step. QFileSystemWatcher::removePath() returns false when trying to remove the subdirectory path, and QFileSystemWatcher::directories() show that directory in the paths being watched. Same as posted here https://bugreports.qt-project.org/browse/QTBUG-10846
Since step 1 fails here, step 2 also fails and i cannot rename the parent dir.
I am using Qt5.2.1 and Windows 7.
Kindly help me with a resolution.
c++ - QtServiceFramework/QServicePluginInterface:没有这样的文件或目录
在构建我的 qt 项目时,我遇到了以下错误。如何解决这个问题,我是否需要安装任何插件,如果是,它们是什么以及在哪里可以找到它们。提前致谢。
致命错误:QtServiceFramework/QServicePluginInterface:没有这样的文件或目录
编译终止。
c++ - 自定义 QWidget 不继承父样式表
我有一个自定义的 QWidget 类,它似乎没有像我理解的那样继承其父样式表。我在自定义类的构造函数中打印出父样式表,它绝对是具有正确样式表的正确父样式表。
但是,我发现如果我在构造函数中调用它,我可以让它工作:
我的理解是,这不应该是必要的。我的程序中的其他小部件似乎不需要它。我做错了什么会阻止它工作?
qt - 在触摸屏中聚焦小部件的问题
我有一个包含一些行编辑的 QWidget。当 Line 编辑获得焦点时,我必须弹出一个新的 Numpad 小部件。当我单击 Numpad 小部件时,焦点必须保留在 Line 编辑小部件中。所以我尝试使用
这对于小键盘小部件的鼠标点击效果很好,但我使用的是触摸屏。当我触摸 Numpad 小部件时,LineEdit 小部件上有闪烁(标题栏闪烁效果)。所以谁能告诉我我必须使用哪个宏来阻止小部件在触摸屏上的焦点。
我尝试使用WM_Touch宏,这导致没有正确的输出。请帮忙……</p>
c++ - 确定 QKeyEvent 的来源
我有一个Qt
应用程序,其中包含多个同时显示按钮的小部件。在某些情况下,我希望将按键发送到其中一个小部件,即使该小部件没有焦点。为此,我keyPressEvent()
在主小部件(拥有此应用程序中的所有子小部件)中进行了覆盖,如果它没有焦点,则使用与此类似的代码将键事件重新发送到子小部件:
只要someWidget
处理所说的事件,这很有效。如果它忽略它,那么它会进入一个讨厌的无限递归循环,因为事件会流向父母。
有没有办法知道事件来自哪里,这样我就可以防止这个无限循环?我在想这样的事情:
还是有其他方法可以防止这种情况发生?
c++ - QTableView 行样式
我有一个 QTableView 组件在行中显示几种类型的数据。我需要的是用不同的颜色显示每种类型的行。我的样式表如下所示:
我有两个想法如何实现这一目标:
使用
data()
模型中的方法并响应Qt::BackgroundColorRole
. 不幸的是,当我这样做时,背景颜色被忽略,直到我border: 0px;
从样式表中删除,当我删除边框时,styleshhet 的填充被忽略。奇怪的...为每种类型的行设置一个 CSS/QSS 类并在样式表中设置它们的颜色。然后使用模型为每种类型的行分配一个适当的类。所以样式表看起来像这样:
我更喜欢这种方法,因为它将内容与外观分开,但我不知道该怎么做。也许使用 ItemDelegate?
请问,有没有人知道一个好的和简单的解决方案?
亲切的问候和非常感谢。
简