Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.3k Topics 455.9k Posts
  • Build QT 6.8 for Ubuntu 20.04 ERROR

    Unsolved
    10
    0 Votes
    10 Posts
    1k Views
    J
    Why such an old Ubuntu? Just looking briefly at the error my guess is that QT 6.8 code expects a newer openssl library than what's available on your machine. I compiled the latest QT 6.8 branch on Ubuntu 24.04 today without any compilation errors.
  • encrypt decrypt json files using cryptopp

    Solved
    5
    0 Votes
    5 Posts
    371 Views
    Axel SpoerlA
    Please don’t delete topics. Mark them solved if they are.
  • Cuda cmake

    Unsolved
    1
    0 Votes
    1 Posts
    182 Views
    No one has replied
  • This topic is deleted!

    Locked Unsolved
    2
    0 Votes
    2 Posts
    5 Views
  • [SOLVED] How to resize a window to it's minimum when launched?

    8
    1 Votes
    8 Posts
    3k Views
    RokeJulianLockhartR
    @JonB, it actually appears that it works on one (example) script: #!/usr/bin/env -S python3 import sys from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("My App") self.button = QPushButton("Press Me!") self.button.clicked.connect(self.the_button_was_clicked) self.resize(self.minimumSizeHint()) self.setCentralWidget(self.button) def the_button_was_clicked(self): self.button.setText("You already clicked me.") self.button.setEnabled(False) # Also change the window title. self.setWindowTitle("My Oneshot App") app = QApplication(sys.argv) window = MainWindow() window.show() app.exec() ...but not another, (more) complex one: #!/usr/bin/env -S python3 ##### **Description** """ This allows management of the brightness of a monitor. It features multiple methods of interaction, and operates upon Windows and traditional Linux distributions (Fedora and OpenSUSE). """ ##### **Dependency Importation** import calendar import time from rich.console import Console from rich.markdown import Markdown #**Origin(s)**: [Stack Overflow](https://stackoverflow.com/revisions/76833666/1#:~:text=from%20rich.console%20import%20Console,%20%20%20%20console.print(md)) ##### **Metadata Definition** __LICENSE__: str = ["MIT"] __COPYRIGHT__: str = ["Copyright 2024 Roke Julian Lockhart Beedell"] __STATUS__: list = ["alpha"] __VERSION__: list = ["1720556480"] __MAINTAINERS__: list = ["[`RokeJulianLockhart`](https://dub.sh/jga)"] __CREDITS__: list = ["[`RokeJulianLockhart`](https://dub.sh/jga)"] if __name__ == "__main__": #**Information**: As [this](https://realpython.com/if-name-main-python/#:~:text=What%20Does%20if%20__name__%20==%20%22__main__%22%20Do%20in%20Python?) explains, this prevents invocation as a module, restricting it to run solely as a script. import sys if sys.version_info[0] != 3 or sys.version_info[1] < 7: #**Origin(s)**: [Avoiding `__init__.py` for Initial Imports](https://stackoverflow.com/revisions/6224814/2#:~:text=You%20should%20not%20use%20any,including%20real%20initial%20imports%2C%20here) logging.getLogger().debug( Console().print(Markdown( 'This script requires Python version 3.'))) raise SystemExit(-1) #**Information**: [Understanding `sys.exit(n)` in Python](https://stackoverflow.com/revisions/44894090/2#:~:text=The%20call%20sys.exit(n)%20tells%20the,answered) #**Task(s)**: convert to `wxwidgets`/`wxpython`?: \ #1. [wxWidgets Issue 19352: Migrated from Trac Ticket](https://github.com/wxWidgets/wxWidgets/issues/19352#issue-1100648687:~:text=Issue%20migrated%20from%20trac%20ticket,Thanks%20a%20lot!) #1. [wxWidgets: wxQt Project Information](https://www.wxwidgets.org/about/#:~:text=10%20and%0Aabove.-,wxqt,-%3A%20wxQt%20is%20a) ##### **Dependency Importation** import platform import subprocess import logging import shutil #```py #logging.basicConfig(level=logging.DEBUG) # #**Task(s)**: fix [*Placeholder*](https://github.com/Crozzers/screen_brightness_control/discussions/30#discussion-5041474) \. # #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/revisions/41797120/1#:~:text=Try%20this-,logging.basicConfig(level=logging.DEBUG),-answered%20Jan%2022%2C) #``` ##### **Dependency Management** def which(package): """ A function that takes a package name as input, tries to import the package, and if it fails, installs the package using pip. Parameters: package (str): The name of the package to import or install. Returns: None """ try: return __import__(package) except ImportError: subprocess.check_call([sys.executable, "-m", "pip", "install", package]) #**Origin(s)**: [Installing Python Packages with `pip` from Script](https://stackoverflow.com/revisions/50255019/2#:~:text=The%20officially%20recommended%20way%20to,subprocess.check_call(%5Bsys.executable%2C%20%22%2Dm%22%2C%20%22pip%22%2C%20%22install%22%2C%20package%5D)) #**Origin(s): [*Placeholder*](https://stackoverflow.com/revisions/4527622/3#:~:text=package%20=%20'package_name',%20%20%20%20return%20None) logging.getLogger().debug( Console().print(Markdown( package, 'exists.'))) which(package='screen_brightness_control') which(package='PyQt5') which(package='rich') #```py #subprocess.check_call([sys.executable, "-m", "pip", "install", 'PySide6']) #**Task(s)**: ascertain whether this should be used instead, since it is official. https://www.pythonguis.com/faq/pyqt6-vs-pyside6/#:~:text=PySide2-,PyQt6%20vs%20PySide6,-What's%20the%20difference #``` ##### **Dependency Importation** import screen_brightness_control as sbc from PyQt5.QtWidgets import QMenu, QMenuBar, QApplication, QMainWindow, QVBoxLayout, QWidget, QSlider, QLineEdit, QPushButton, QTreeWidget, QTreeWidgetItem #**Task(s)**: replace with PyQt6. from PyQt5 import QtCore #**Task(s)**: replace with PyQt6. from PyQt5.QtCore import Qt #**Task(s)**: replace with PyQt6. ##### **Security** if platform.system() == 'Linux': import getpass import grp import os if getpass.getuser() not in str( subprocess.call(["powershell", "".join( [os.path.dirname(os.path.realpath(__file__)), ''])])): # <code>../ [-] `{title: "Configurator", id: "s3wrcl"}`{.JSON5}.dir/ [-] `{title: "Code", id: ""}`{.JSON5}.dir/ [x] ``{title: "`Get-SuperuserUsername`{.PS1}", id: "settlu"}``{.JSON5}.txt.PS1</code> #**Origin(s)**: \ #1. [*Placeholder*](https://stackoverflow.com/revisions/842096/4#:~:text=Look%20at%20getpass%20module,May%208%2C%202009%20at%2022:30) #1. [`in`](https://stackoverflow.com/revisions/3437070/7#:~:text=Use%20the%20in%20operator:,Note:%20This%20is%20case%2Dsensitive.) #1. [*Placeholder*](https://stackoverflow.com/revisions/3430395/13#:~:text=The%20special%20variable%20__file__%20contains,does%20the%20__file__%20variable%20mean/do?) #1. [*Placeholder*](https://stackoverflow.com/revisions/40311142/3#:~:text=For%20your%20stated%20scenario%2C%20there,Oct%2028%2C%202016%20at%2018:29) logging.getLogger().debug( logging.getLogger().debug( Console().print(Markdown( getpass.getuser(), 'is not the superuser.')))) #**Task(s)**: Fix concatenation problems: `.debug("Houston, we have a %s", "thorny problem", exc_info=1)` works. try: grp.getgrnam('i2c') except Exception: try: subprocess.call(['sudo', 'groupadd', '--system', 'i2c']) grp.getgrnam('i2c') except Exception: logging.exception('Unable to create group i2c.') raise SystemExit(-1) else: logging.getLogger().debug( Console().print(Markdown( 'i2c exists.'))) if not [match for match in grp.getgrnam('i2c').gr_mem if getpass.getuser() in match]: #**Information**: [*Placeholder*](https://www.ddcutil.com/i2c_permissions/#:~:text=I2C%20Device%20Permissions-,I2C%20Device%20Permissions,$%20sudo%20chmod%20a+rw%20/dev/i2c%2D*,-Previous) \ #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/revisions/15168560/2#:~:text=This%20answer%20builds%20upon%20the,print('Group%20somegrp%20does%20not%20exist.')) logging.exception(getpass.getuser(), 'is not part of the i2c group.') if subprocess.call(['sudo', 'usermod', getpass.getuser(), '-aG', 'i2c']) != 0: logging.exception('Unable to add user to i2c.') raise SystemExit(-1) else: logging.getLogger().debug( Console().print(Markdown( getpass.getuser(), 'added to i2c.'))) else: logging.getLogger().debug( Console().print(Markdown( getpass.getuser(), 'is part of i2c.'))) import shutil ddcutil_available = False logging.getLogger().debug( Console().print(Markdown( '0: ddcutil_available = False'))) if shutil.which('ddcutil') is None: logging.getLogger().error( Console().print(Markdown( 'Code RSJQ4A: the ddcutils binary is unavailable.'))) ddcutil_available = False logging.getLogger().debug( Console().print(Markdown( '1: ddcutil_available = False'))) elif os.path.exists(shutil.which('ddcutil')): ddcutil_available = True logging.getLogger().debug( Console().print(Markdown( '2: ddcutil_available = True'))) else: ddcutil_available = False logging.getLogger().error( Console().print(Markdown( 'Invalid output of shutil. Defaulting to assumption that ddcutil is unavailable.'))) if (sbc.list_monitors(method='ddcutil') == sbc.list_monitors()) == False: logging.getLogger().error( Console().print(Markdown( 'Code RSJPK5: ddcutils is unable to acquire the list of monitors. Operations may become slow.'))) ddcutil_available = False logging.getLogger().debug( Console().print(Markdown( '3: ddcutil_available = False'))) elif (sbc.list_monitors(method='ddcutil') == sbc.list_monitors()) == True: logging.getLogger().debug( Console().print(Markdown( '4: ddcutil is available.'))) ddcutil_available = True logging.getLogger().debug( Console().print(Markdown( '5: ddcutil_available = True'))) else: logging.exception( Console().print(Markdown( 'ddcutil_available contains invalid value.'))) raise Exception(1) ##### **GUI** class MainWindow(QMainWindow): """ * The class `MainWindow` inherits from `QMainWindow` and sets up a main window layout with monitor information. * `__init__`: Initializes the main window layout, sets up monitor list, slider, input area, and apply configuration button. * `on_click`: Handles the logic for applying the configuration to every checked monitor in the list. """ def __init__(self, *args, **kwargs): """ Initializes the MainWindow class. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: None """ super(MainWindow, self).__init__(*args, **kwargs) layout_1 = QVBoxLayout() layout_1.setAlignment(QtCore.Qt.AlignTop) widget_1 = QWidget() widget_1.setLayout(layout_1) self.setCentralWidget(widget_1) self.resize(self.minimumSizeHint()) monitor_list = QTreeWidget() layout_1.addWidget(monitor_list) #```py #monitor_list.setWindowTitle('Monitors') # #**Task(s)**: ascertain what this does. #``` headers = (['Model', 'Brightness']) monitor_list.setColumnCount(len(headers)) monitor_list.setHeaderLabels(headers) counter = 0 if ddcutil_available == True: #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/revisions/11269627/7#:~:text=For%20python%20%3E=%203.3%2C%20Redirect,=%20os.system(%22echo%20'foo'%20%26%3E%20/dev/null%22)) while counter < len(sbc.list_monitors(method='ddcutil')): #**Task(s)**: this doesn't operate with more than 1 monitor attached. rowcount = monitor_list.topLevelItemCount() monitor_list.addTopLevelItem(QTreeWidgetItem(rowcount)) monitor_list.topLevelItem(rowcount).setText(rowcount, sbc.list_monitors(method='ddcutil')[counter]) if sbc.list_monitors(method='ddcutil')[rowcount] == sbc.list_monitors(method='ddcutil')[0]: monitor_list.topLevelItem(rowcount).setSelected(True) #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/posts/30213421/revisions#:~:text=You%20can%20interact%20with%20the,%7D) else: monitor_list.topLevelItem(rowcount).setSelected(False) monitor_list.topLevelItem(rowcount).setCheckState(rowcount, QtCore.Qt.Unchecked) monitor_list.topLevelItem(rowcount).setFlags(monitor_list.topLevelItem(rowcount).flags() | QtCore.Qt.ItemIsUserCheckable) counter = counter + 1 if ddcutil_available == False: while counter < len(sbc.list_monitors()): #**Task(s)**: this doesn't operate with more than 1 monitor attached. rowcount = monitor_list.topLevelItemCount() monitor_list.addTopLevelItem(QTreeWidgetItem(rowcount)) monitor_list.topLevelItem(rowcount).setText(rowcount, sbc.list_monitors()[counter]) if sbc.list_monitors()[rowcount] == sbc.list_monitors()[0]: monitor_list.topLevelItem(rowcount).setSelected(True) #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/posts/30213421/revisions#:~:text=You%20can%20interact%20with%20the,%7D) monitor_list.topLevelItem(rowcount).setCheckState(rowcount, QtCore.Qt.Checked) else: monitor_list.topLevelItem(rowcount).setSelected(False) monitor_list.topLevelItem(rowcount).setCheckState(rowcount, QtCore.Qt.Unchecked) monitor_list.topLevelItem(rowcount).setFlags(monitor_list.topLevelItem(rowcount).flags() | QtCore.Qt.ItemIsUserCheckable) counter = counter + 1 if not platform.system() == 'Windows' and not platform.system() == 'Darwin': logging.getLogger().debug( Console().print(Markdown( "Unknown and consequently unsupported platform."))) #```py #for monitor in sbc.list_monitors(): # logging.getLogger().debug( # Console().print(Markdown( # monitor, ':', sbc.get_brightness(display=monitor), '%')) #``` chosen_display = 0 slider = QSlider(Qt.Orientation.Horizontal, self) layout_1.addWidget(slider) slider.setRange(0, 100) #**Task(s)**: add checkbox to override chosen colour with value provided by external device (brightness sensor) #```py #label = QLabel(sbc.list_monitors()[chosen_display], self) #layout_1.addWidget(label) # #**Task(s)**: this should be to the left of the input box. #``` if ddcutil_available == True: #**Origin(s)**: [Redirecting Output to `/dev/null` in Python 3.3+](https://stackoverflow.com/revisions/11269627/7#:~:text=For%20python%20%3E=%203.3%2C%20Redirect,=%20os.system(%22echo%20'foo'%20%26%3E%20/dev/null%22)) slider.setValue(sbc.get_brightness(method='ddcutil')[0]) #**Task(s)**: discover whether specification of a method is necessary, and if so, which to utilize. elif ddcutil_available == False: slider.setValue(sbc.get_brightness()[0]) #**Information**: `sbc.get_brightness(method='ddcutil')` is significantly more quick. if not platform.system() == 'Windows' and not platform.system() == 'Darwin': logging.getLogger().debug( Console().print(Markdown( "Unknown and consequently unsupported platform."))) input_area = QLineEdit(self) layout_1.addWidget(input_area) if ddcutil_available == True: #**Information**: [Pylint Singleton Comparison Convention](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/singleton-comparison.html) input_area.setPlaceholderText(str(sbc.get_brightness(method='ddcutil')[chosen_display])) #**Task(s)**: discover whether specification of a method is necessary, and if so, which to utilize. else: input_area.setPlaceholderText(str(sbc.get_brightness()[chosen_display])) #**Task(s)**: discover whether specification of a method is necessary, and if so, which to utilize. if not platform.system() == 'Windows' and not platform.system() == 'Darwin': logging.getLogger().debug( Console().print(Markdown( "Unknown and consequently unsupported platform."))) application = QPushButton('Apply configuration', self) layout_1.addWidget(application) #```py #def onSlide(slider): # input_area.setPlaceholderText(slider.value()) #slider.valueChanged.connect(slider.valueChanged) #``` #**Information**: [*Placeholder*](https://www.reddit.com/r/QtFramework/comments/10ac5kg/comment/j4734je/?utm_source=share&utm_medium=web2x&context=3) def on_click(): #**Task(s)**: Use [*Placeholder*](https://stackoverflow.com/a/60785652/9731176) to apply to every checked monitor in list. if ddcutil_available == True: #**Information**: [*Placeholder*](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/singleton-comparison.html) sbc.set_brightness(slider.value(), method='ddcutil') #**Origin(s)**: [*Placeholder*](https://stackoverflow.com/a/15765621/9731176) input_area.setPlaceholderText(str(sbc.get_brightness(method='ddcutil')[chosen_display])) elif ddcutil_available == False: sbc.set_brightness(slider.value()) input_area.setPlaceholderText(str(sbc.get_brightness()[chosen_display])) if not platform.system() == 'Windows' and not platform.system() == 'Darwin': logging.getLogger().debug( Console().print(Markdown( "Unknown and consequently unsupported platform."))) application.clicked.connect(on_click) application.click() #**Information**: [*Placeholder*](https://forum.qt.io/topic/94834/differences-between-qapplication-qguiappication-qcoreapplication-classes?_=1720556789808&lang=en-GB#:~:text=QCoreApplication%20%2D%20base%20class.%20Use,starts%20when%20you%20call%20app.exec();.) app = QApplication #**Information**: \ #1. Set attributes before `sys.argv` is passed to `QApplication` constructor. #1. [*Placeholder*](https://medium.com/analytics-vidhya/how-to-build-your-first-desktop-application-in-python-7568c7d74311#:~:text=the%20qquickwindow.setscenegraphbackend('software')%20should%20be%20included%20in%20your%20code%20as%20a%20fallback%20option%20for%20uses%20with%20old%20hardware%20specs%2C%20other%20than%20that%20they%20would%20see%20an%20error%20information%20as%20seen%20below%3A) from PyQt6.QtQuick import QQuickWindow QQuickWindow.setTextRenderType( QQuickWindow.TextRenderType.NativeTextRendering) #**Information**: Should enable High DPI scaling, but isn't necesssary for Qt6. app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) #**Information**: [Ensures that widgets have native windows.](https://doc.qt.io/qt-6/qt.html#:~:text=qt%3A%3Aaa_nativewindows) app.setAttribute(QtCore.Qt.AA_NativeWindows, True) app = QApplication(sys.argv) main_window = MainWindow() main_window.show() #**Information**: Hardcoded exit code unnecessary because `sys.exit()` provides it. sys.exit(app.exec()) #**Information**: [`exec()` rather than `exec_()` is due to non-backward compatbility.](https://stackoverflow.com/revisions/22614643/4#:~:text=That's%20because%20until%20Python%203%2C,methods%20have%20been%20removed.%20...) raise SystemExit(-1) ...per: [image: 0JZ6ARW.mp4] I suppose that that means that I'm doing something in one of the scripts that is incompatible with the command, rather than the operation itself being unsupported. Apologies if so.
  • Macdeployqt creates much larger files with 6.7

    Unsolved
    3
    0 Votes
    3 Posts
    190 Views
    johngodJ
    Not sure it is related but you may want to check this post https://forum.qt.io/topic/150037/my-mac-app-bundle-is-mostly-dsym-why
  • Need Qt 5.15.2 for xStudio Windows Build - Not Available in Online Installer

    Unsolved
    12
    0 Votes
    12 Posts
    667 Views
    SGaistS
    You have some threading issues in your application. You should sort that as well.
  • senderSignalIndex() not accessible

    Solved
    9
    0 Votes
    9 Posts
    302 Views
    GrecKoG
    note that sender(), senderSignalIndex() are quite expensive calls (they involves a mutex) and can most of the time be refactoring to connect to a lambda capturing the calling context.
  • Qt Creator, how to install older version?

    Solved
    10
    0 Votes
    10 Posts
    23k Views
    N
    I asked this question recently on StackOverflow along with my solution: How do I install a specific version of Qt Creator? To reiterate, I was struggling with Qt Creator 14.0.0 being very unstable (crashes when you do most things using the .ui file designer), so I wanted to go back to Qt Creator 13.x which seemed a bit more stable (though the designer does still segfault a bit more than I'd expect... I plan to raise a bug report next time it happens but it's been a few days). Qt publishes Qt Creator packages on their Qt Creator GitHub project. For example, you can search for v13. I tested the .deb and it works well. [Instructions]
  • Wrong text display : Qt 5.14 only

    Solved qml qt 5.14 text corruption character encod
    18
    0 Votes
    18 Posts
    3k Views
    A
    @es-w Did you ever figure anything out on this? I'm having the same issue with QML in Qt 5.15.8 where some text is incorrect on the same screen as some correct text. I also explicitly set the font to Roboto prior to displaying any QML. The weird part is, is the same build works on one Red Hat VM, but does not work on a slightly different RH VM.
  • Add item to combobox when it is "touched"

    Unsolved
    9
    0 Votes
    9 Posts
    643 Views
    M
    I achieved something similar by subclassing QComboBox and adding the aboutToShow signal myself. I override the showPopup method so it emits the signal before showing the comboBox options.
  • Is omitting a necessary Q_OBJECT always detected at build time?

    Solved
    8
    0 Votes
    8 Posts
    432 Views
    D
    @jeremy_k You are right, thanks! So, for example, you have a class, MyClass, which inherits QObject. If MyClass is declared with Q_OBJECT, MyClass::staticMetaObject.className() evaluates to "MyClass", whereas if MyClass is declared without Q_OBJECT, the same expression evaluates to "QObject". Both versions build without error, but the one without Q_OBJECT does not work as intended. Of the listed features, however, the only ones we use are QObject::setProperty() and QObject::property(), but only in a very few places, and not on classes of our own (i.e., on classes of the Qt library). Therefore, we should be safe as far as these features are concerned. Please let us know if you can think of other examples.
  • BMP imageformat missing

    Unsolved
    2
    0 Votes
    2 Posts
    128 Views
    Pl45m4P
    @franco-amato https://doc.qt.io/qt-5/qtimageformats-index.html BMP is supported by default as one of the standard formats for images https://doc.qt.io/qt-5/qimage.html#reading-and-writing-image-files
  • Synchronization with QVulkanWindow

    Unsolved
    4
    0 Votes
    4 Posts
    286 Views
    J
    @SimonSchroeder My application is using 1 thread.
  • With Qt/MSBuild generated static lib is only 1MB... why?

    Unsolved
    8
    0 Votes
    8 Posts
    526 Views
    K
    Without the ugly workaround of using "additional dependencies" here's the full commandline options for the migrated VS project. I really don't see what could be the problem. /permissive- /MP /ifcOutput "C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI" /GS /analyze- /W3 /Zc:wchar_t /I"." /I"release" /I".\GeneratedFiles" /I"C:\Git\GLideN64\projects\msvc....\src\osal" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include" /I"C:\Git\GLideN64\projects\msvc" /I"C:\Users\Kim\AppData\Local\Temp\bnz5mksk.no3" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include\QtUiTools" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include\QtWidgets" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include\QtWinExtras" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include\QtGui" /I"C:\Qt\qt-5_15-x86-msvc2019-static\include\QtCore" /I"C:\Qt\qt-5_15-x86-msvc2019-static\mkspecs\win32-msvc" /I"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI\moc" /I"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI\uic" /Gm- /O2 /Fd"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI\vc16.0.pdb" /Zc:inline /fp:precise /D "QT_NO_DEBUG" /D "NDEBUG" /D "OS_WINDOWS" /D "_WINDOWS" /D "UNICODE" /D "WIN32" /D "QT_STATICPLUGIN" /D "_UNICODE" /D "_ENABLE_EXTENDED_ALIGNED_STORAGE" /D "QT_UITOOLS_LIB" /D "QT_WIDGETS_LIB" /D "QT_WINEXTRAS_LIB" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /Oy- /MT /std:c++17 /FC /Fa"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI" /EHsc /nologo /Fo"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI" /Fp"C:\Git\GLideN64\projects\msvc\build\Win32\Release\GLideNUI\GLideNUI.pch" /diagnostics:column /OUT:"C:\Git\GLideN64\projects\msvc\bin\Win32\Release\lib\GLideNUI.lib" /LTCG "imm32.lib" "Ws2_32.lib" /MACHINE:X86 /NOLOGO /LIBPATH:"C:\Qt\qt-5_15-x86-msvc2019-static\lib"
  • QTableWidget setColumnWidth didn't work in Qt6, but work in Qt5

    Unsolved
    6
    0 Votes
    6 Posts
    396 Views
    Christian EhrlicherC
    Upgrade to a more recent version: https://bugreports.qt.io/browse/QTBUG-122109
  • 0 Votes
    3 Posts
    188 Views
    C
    I case it helps further, QObject::~QObject() says: Destroys the object, deleting all its child objects. All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is often safer to use deleteLater() rather than deleting a QObject subclass directly. Emphasis mine.
  • 0 Votes
    4 Posts
    453 Views
    J
    @SimonSchroeder I added the Throttle class to implement low-frequency send signals #include <type_traits> #include <tuple> #include <QTimer> #include <QCoreApplication> namespace QtUtility { template <typename T> struct lambda_traits : lambda_traits<decltype(&T::operator())> {}; template <typename ClassType, typename ReturnType, typename... Args> struct lambda_traits<ReturnType(ClassType::*)(Args...) const> { static const std::size_t arity = sizeof...(Args); }; template<typename Func, std::size_t... Is, typename... Args> void static call_slot(Func slot, std::index_sequence<Is...>, Args&&... args) { slot(std::get<Is>(std::forward_as_tuple(std::forward<Args>(args)...))...); } class MyTimer : public QTimer { public: using QTimer::QTimer; std::function<void()> func; }; } class Debounce : QObject { public: int interval = 200; Debounce(int v, QObject* parent = NULL) { interval = v; setParent(parent ? parent : QCoreApplication::instance()); } template <typename Func1, typename Func2> inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object* sender, Func1 signal, const QObject* context, Func2 slot, Qt::ConnectionType type = Qt::AutoConnection) { using namespace QtUtility; auto timer = new MyTimer((QObject*)sender); timer->setSingleShot(true); QObject::connect(sender, signal, timer, [=](auto&&... args) {timer->func = [=]() {call_slot(slot, std::make_index_sequence<lambda_traits<Func2>::arity>(), (args)...); }; timer->start(interval); }); return QObject::connect(timer, &QTimer::timeout, context, [=]() {timer->func(); }, type); } }; class Throttle : QObject { public: int interval = 200; Throttle(int v, QObject* parent = NULL) { interval = v; setParent(parent ? parent : QCoreApplication::instance()); } template <typename Func1, typename Func2> inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object* sender, Func1 signal, const QObject* context, Func2 slot, Qt::ConnectionType type = Qt::AutoConnection) { using namespace QtUtility; auto timer = new MyTimer((QObject*)sender); timer->setSingleShot(true); QObject::connect(sender, signal, timer, [=](auto&&... args) {timer->func = [=]() {call_slot(slot, std::make_index_sequence<lambda_traits<Func2>::arity>(), (args)...); }; if (!timer->isActive()) timer->start(interval); }); return QObject::connect(timer, &QTimer::timeout, context, [=]() {timer->func(); }, type); } }; #include <QApplication> #include <QSlider> #include <QDoubleSpinBox> #include <QWheelEvent> int main(int argc, char* argv[]) { QApplication app(argc, argv); auto w = new QWidget(); auto sl = new QSlider(Qt::Horizontal, w); auto dsp = new QDoubleSpinBox(w); w->show(); sl->move(30, 30); w->resize(200, 100); { auto db = new Debounce(200); auto thr = new Throttle(200); QObject::connect(dsp, QOverload<double>::of(&QDoubleSpinBox::valueChanged), dsp, [=](double v) { emit sl->rangeChanged(0, v); }); db->connect(dsp, QOverload<double>::of(&QDoubleSpinBox::valueChanged), dsp, [=](double v) { printf("QDoubleSpinBox %f \n", v); }); db->connect(sl, &QSlider::valueChanged, sl, []() {printf("QSlider1 \n "); }); db->connect(sl, &QSlider::valueChanged, sl, [](int v) {printf("QSlider2 %d \n", v); }); thr->connect(sl, &QSlider::rangeChanged, sl, [](int v0, int v1) {printf("rangeChanged %d %d\n", v0, v1); }); } return app.exec(); }
  • Need help finding a problem with my OAuth flow

    Unsolved
    1
    0 Votes
    1 Posts
    99 Views
    No one has replied
  • The problem between HTTP and QEvetnLoop

    Unsolved
    7
    0 Votes
    7 Posts
    258 Views
    J
    @sierdzio ok,I try it,thank you