qt

Qt QFileDialog - native dialogs only with static functions?

二次信任 提交于 2021-02-07 13:16:52
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

Qt QFileDialog - native dialogs only with static functions?

不想你离开。 提交于 2021-02-07 13:15:56
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

Creating a resource file to use it in Qt Designer

瘦欲@ 提交于 2021-02-07 12:35:42
问题 I want to add a background image to a widget and thus I need a resource file but I am not able to create it in Qt Designer. Here is what I did: From the widget I go to the resources browser and click on the "add new file" button then a new window pops up. I am asked to point to the .qrc file but this file does not exist and I don't know how to create it. I googled and found that .qrc files are created using Qt Creator. Can't I create a .qrc file in Qt Designer ? Do I need to use Qt Creator to

Format a Number to a specific QString format

穿精又带淫゛_ 提交于 2021-02-07 11:25:20
问题 I have a question about formatting a decimal number to a certain QString format. Basically, I have an input box in my program that can take any values. I want it to translate the value in this box to the format "+05.30" (based on the value). The value will be limited to +/-99.99. Some examples include: .2 --> +00.02 -1.5 --> -01.50 9.9 --> +09.90 I'm thinking of using a converter like this, but it will have some obvious issues (no leading 0, no leading + sign). QString temp = QString::number

Format a Number to a specific QString format

谁都会走 提交于 2021-02-07 11:25:13
问题 I have a question about formatting a decimal number to a certain QString format. Basically, I have an input box in my program that can take any values. I want it to translate the value in this box to the format "+05.30" (based on the value). The value will be limited to +/-99.99. Some examples include: .2 --> +00.02 -1.5 --> -01.50 9.9 --> +09.90 I'm thinking of using a converter like this, but it will have some obvious issues (no leading 0, no leading + sign). QString temp = QString::number

Code freezes on trying to open QDialog

混江龙づ霸主 提交于 2021-02-07 10:28:41
问题 I'm trying to debug a c++/Qt5.5 code in MSVS2010 Professional. A function has following lines of code, /* Static method approach */ QString filters("Music files (*.mp3);;Text files (*.txt);;All files (*.*)"); QString defaultFilter("Text files (*.txt)"); QFileDialog::getSaveFileName(0, "Save file", QDir::currentPath(), filters, &defaultFilter); The dialog is simply doesn't open and the application freezes. I tried the alternative was as below. /* Direct object construction approach */

PySide2 QThread Error: QThread: Destroyed while thread is still running

旧街凉风 提交于 2021-02-07 10:07:21
问题 I am new to PySide2. I am just trying to launch a sample application and start a thread as the application starts and want to stop the thread as the application closes. When I am closing the application I am getting the following error: QThread: Destroyed while the thread is still running. The sample_ui.py is a python file that I converted from sample_ui.ui Code: import time import sys import sample_ui from PySide2 import QtWidgets from PySide2 import QtCore class MainWindow(QtWidgets

How to capture full web page using QtWebEngine?

此生再无相见时 提交于 2021-02-07 10:04:53
问题 I use the following code in a QWebEngineView object to capture a web page to an image: image=new QImage(w,h, QImage::Format_ARGB32); painter = new QPainter(image); render(painter); image->save(imagefilename); Unfortunately, it only renders part of the web page that is shown on the widget to the image. How to render the whole page to the image? 回答1: It is possible to hide webview and resize it to show the whole web page. I'm using PyQt5 (version 5.12), but the idea should apply to C++ Qt as

PySide2 QThread Error: QThread: Destroyed while thread is still running

浪尽此生 提交于 2021-02-07 10:04:32
问题 I am new to PySide2. I am just trying to launch a sample application and start a thread as the application starts and want to stop the thread as the application closes. When I am closing the application I am getting the following error: QThread: Destroyed while the thread is still running. The sample_ui.py is a python file that I converted from sample_ui.ui Code: import time import sys import sample_ui from PySide2 import QtWidgets from PySide2 import QtCore class MainWindow(QtWidgets

How to change the Mac OS X Keyboard Layout programmatically?

蓝咒 提交于 2021-02-07 09:33:53
问题 My Qt app supports changing input language on Linux and Windows. I want to add support for changing the input language in Mac OSX, too. Unfortunately I don't have any information about the Mac SDK. (My first and last work with OS X was compiling Qt and compiling my app!) I googling this problem and found that I need to use Text Input Source Services and also I found these codes: TISInputSourceRef isref; isref = TISCopyCurrentKeyboardInputSource(); CFDataRef uchr = (CFDataRef