Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.5k Posts
  • Signal QLowEnergyController::connected/disconnected is not emitted in Qt 6.7

    Unsolved
    5
    0 Votes
    5 Posts
    370 Views
    A
    I've encountered the same. But this time on iOS, whereby the stateChanged signal stays stuck in ConnectedState, even if the central device disconnects.
  • Don't play mp3

    Solved
    12
    0 Votes
    12 Posts
    274 Views
    M
    it's work with vlc #pragma once #include <QObject> #include <vlc/vlc.h> #include <QString> #include <QUrl> #include <QTimer> class VlcAudioPlayer : public QObject { Q_OBJECT public: explicit VlcAudioPlayer(QObject* parent = nullptr); ~VlcAudioPlayer(); // Запустить воспроизведение аудиофайла по локальному пути bool play(const QString& filePath); // Остановить воспроизведение void stop(); // Проверить, играет ли сейчас аудио bool isPlaying() const; signals: void started(); void stopped(); void finished(); private slots: void checkPlayback(); private: libvlc_instance_t* m_instance = nullptr; libvlc_media_player_t* m_mediaPlayer = nullptr; QTimer m_timer; }; #include "VlcAudioPlayer.h" #include <QDebug> VlcAudioPlayer::VlcAudioPlayer(QObject* parent) : QObject(parent) { const char* args[] = { "--no-xlib" }; m_instance = libvlc_new(1, args); if (!m_instance) { qWarning() << "Failed to create libVLC instance"; } m_mediaPlayer = nullptr; // Таймер для проверки состояния воспроизведения connect(&m_timer, &QTimer::timeout, this, &VlcAudioPlayer::checkPlayback); m_timer.setInterval(200); // проверять каждые 200 мс } VlcAudioPlayer::~VlcAudioPlayer() { if (m_mediaPlayer) { libvlc_media_player_stop(m_mediaPlayer); libvlc_media_player_release(m_mediaPlayer); } if (m_instance) { libvlc_release(m_instance); } } bool VlcAudioPlayer::play(const QString& filePath) { if (!m_instance) { qWarning() << "libVLC instance is null"; return false; } // Если уже играет, остановим if (isPlaying()) { stop(); } // Преобразуем путь в URI QUrl url = QUrl::fromLocalFile(filePath); QString uri = url.toString(); libvlc_media_t* media = libvlc_media_new_location(m_instance, uri.toUtf8().constData()); if (!media) { qWarning() << "Failed to create media from URI:" << uri; return false; } if (m_mediaPlayer) { libvlc_media_player_stop(m_mediaPlayer); libvlc_media_player_release(m_mediaPlayer); m_mediaPlayer = nullptr; } m_mediaPlayer = libvlc_media_player_new_from_media(media); libvlc_media_release(media); if (!m_mediaPlayer) { qWarning() << "Failed to create media player"; return false; } if (libvlc_media_player_play(m_mediaPlayer) != 0) { qWarning() << "Failed to start playback"; libvlc_media_player_release(m_mediaPlayer); m_mediaPlayer = nullptr; return false; } emit started(); m_timer.start(); return true; } void VlcAudioPlayer::stop() { if (m_mediaPlayer && isPlaying()) { libvlc_media_player_stop(m_mediaPlayer); emit stopped(); } m_timer.stop(); } bool VlcAudioPlayer::isPlaying() const { if (!m_mediaPlayer) return false; return libvlc_media_player_is_playing(m_mediaPlayer) != 0; } void VlcAudioPlayer::checkPlayback() { if (!m_mediaPlayer) { m_timer.stop(); return; } if (!isPlaying()) { m_timer.stop(); emit finished(); } }
  • Using ASM (x86) with Qt on MacOS with CMake. How?

    Unsolved
    2
    0 Votes
    2 Posts
    75 Views
    I
    @bogong said in Using ASM (x86) with Qt on MacOS with CMake. How?: What is missing by me? That the error messages imply that you try to use x86 assembly but your compilation is targeting arm64 (hence the assembler's complaints about the eax register not existing; and you getting offered ARM mnemonics like movz, probably in response to you trying to use the movl mnemonic which is x86 only). Make sure you target only x86_64 in your build (in CMake, you have CMAKE_OSX_ARCHITECTURES). Or if you want to target ARM, you need to use ARM assembly code which is completely different to x86 assembly. If you are building universal binaries, then you need to write a different version of the inline assembly block for each architecture, and direct to the correct one with preprocessor macros. May I ask why you think you need inline assembly? There is quite possibly an easier approach.
  • Segmentation fault when exiting when linked against Qt 6.9.1

    Solved
    36
    0 Votes
    36 Posts
    3k Views
    Axel SpoerlA
    Thanks @JonB for notifying! The dock widget implementation has some obvious limitations, like e.g. permissions: You can limit allowed main window dock areas, but not the permission to dock on a floating dock. You can’t merge floating docks. That said, we’ll have to take a deeper look and come up with a solid concept for a quick control equivalent. My guess is a year or so. I’ll update this thread in case we have a Jira ticket for input and discussion. In the meanwhile feel free to post ideas here!
  • QVulkanWindow freezes until swapchain recreation on macOS

    Unsolved
    2
    0 Votes
    2 Posts
    142 Views
    C
    Bump... Still an issue for me as well.
  • How to set colors for LineSeries in QtGraphs using C++

    Unsolved
    1
    0 Votes
    1 Posts
    37 Views
    No one has replied
  • 0 Votes
    5 Posts
    196 Views
    EndrII 0E
    thanks, @GrecKo You sent issue is matched with my.
  • QVulkanWindow freezes until window resize on macOS only

    Unsolved
    5
    1 Votes
    5 Posts
    457 Views
    C
    I am experiencing the same issue.. Did you ever find a way to make it work?
  • QFileDialog::getOpenFileName Fails to Display Dialog with Native macOS

    Unsolved
    2
    1 Votes
    2 Posts
    75 Views
    SGaistS
    Hi, Please provide a complete minimal example that shows that issue. This will allow people to test in the same conditions as you.
  • QScatterSeries + QChartView scaling issue

    Solved
    3
    0 Votes
    3 Posts
    76 Views
    A.A.SEZENA
    I use the same method to place candles. I considered sharing it for you, but I decided against it because it might be a more practical solution or might be too complicated. I'm sharing it for variety and to provide the code, as I use it. auto axis = dynamic_cast<QDateTimeAxis *>(a); QDateTime min, max; const unsigned long long imsec = classes->settingsManager->intervalMsec(klines->interval()) / 2; using namespace std::chrono; time_t timeLast = (static_cast<long>(klines->lastDate() + imsec)) / 1000; time_t timeFirst = (static_cast<long>(klines->firstDate() + imsec)) / 1000; min = QDateTime::fromString(ctime(&timeFirst)); max = QDateTime::fromString(ctime(&timeLast)); if (min != axis->min() || max != axis->max()) { axis->setMin(min); axis->setMax(max); axis->setRange(min, max); }
  • Qt::BlockingQueuedConnection not blocking, according to thread sanitizer

    Unsolved
    6
    0 Votes
    6 Posts
    156 Views
    Christian EhrlicherC
    @bobthebuilder said in Qt::BlockingQueuedConnection not blocking, according to thread sanitizer: void copyData() { m_main_data_copy = m_worker_object->m_processed_data; } The thread sanitizer is correct here - you access data from one thread in another without proper locking. It does not know (how should it) that the other thread is sleeping during this operation. From my pov this approach is faulty by design - don't use a blocking connection but store the data e.g. in std::shared_ptr<std::vector<double>>, pass this to your signal and work on a new instance. So no blocking is needed at all and the sanitizer won't blame and it also will work without some Qt magic.
  • Add include directories from sub_directory to main application. How?

    Solved
    7
    0 Votes
    7 Posts
    110 Views
    Christian EhrlicherC
    @bogong said in Add include directories from sub_directory to main application. How?: What is 'correct'? See https://cmake.org/cmake/help/latest/command/target_include_directories.html on how to use target_include_directories() and properly set the include dirs for your libraries. Nothing more to do.
  • How to create delegates that are always editable?

    Unsolved
    6
    0 Votes
    6 Posts
    129 Views
    SGaistS
    It still means that you will have a hundred of widgets at least depending on how you implement your editor opened all the time. That still burns resources for not much benefit.
  • how to solve the problem that using the filedialog component in the qml partion.

    Unsolved
    2
    0 Votes
    2 Posts
    62 Views
    SGaistS
    Hi, You should provide a minimal reproducer example so people will be able to try on their machine. Qt version as well as OS should be provided.
  • Build SQL driver plugin - debug version for MariaDB to be used in VS 2022

    Solved
    4
    0 Votes
    4 Posts
    84 Views
    SGaistS
    Great ! Since you have it working now, please mark the thread as solved using the "Topic Tool" button or the three dotted menu beside the answer you deem correct so other forum users may know a solution has been found :-)
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Right click not working in form designer

    Unsolved
    15
    0 Votes
    15 Posts
    1k Views
    R
    It seems that this is still an issue in Qt Creator/Designer, version 17.0.0 on Linux Ubuntu 22.04. I can select multiple controls in the designer, but I can only add them to a layout in the Object Inspector because right-clicking on the selected controls shows no context menu. (Edit: I'm not sure if this happens all the time or only under special circumstances -- will try to set up a small test.) Has anyone submitted a bug report about this yet?
  • Qlipper not working: 'std::bad_alloc'

    Unsolved
    3
    0 Votes
    3 Posts
    53 Views
    M
    Thanks! Is there maybe another Qt clipboard manager I can use under LXQt, in case I can't fix Qlipper?
  • How to force a style sheet recalculation

    21
    0 Votes
    21 Posts
    28k Views
    W
    @ogoffart you're my hero, I had discovered a weird effect on Qt6.9.1 (and later also on some older Qt6 versions), sending an empty or invalid string to setStyleSheet() didn't always clear the previously set stylesheet, but your proposed solution perfectly works, always! Thanks man!
  • Qt App Preferences Being Restored From A Cached Copy? (QSettings)

    Unsolved
    7
    0 Votes
    7 Posts
    423 Views
    SGaistS
    AFAIK, qml uses QSettings under the hood so it should behave in the same fashion. Damn... I remember experiencing these caching issues while developing but not how I "fixed" it...