Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • QAudioDecoder Fails to start from a thread

    Unsolved
    2
    0 Votes
    2 Posts
    280 Views
    Pl45m4P
    @DukeReddy said in QAudioDecoder Fails to start from a thread: foreach (QFileInfo fileInfo, m_fileInfoList) { AudioDecoder* pDecoder = new AudioDecoder(this); connect(pDecoder, &AudioDecoder::finished, this, &AudioStreamWidget::ThreadFinished); pDecoder->StartDecoding(fileInfo.absoluteFilePath()); pDecoder->start(); //! Thread start } Here you create a new AudioDecoder instance in the GUI thread void AudioDecoder::run() { m_pDecoder = new QAudioDecoder(); m_pDecoder->setSource(m_fileUrl); // .. } and here you create a new instance in AudioDecoder Check out the Qt Thread examples: https://doc.qt.io/qt-6/examples-threadandconcurrent.html and the general threading options with Qt since you are mixing two approaches. https://doc.qt.io/qt-6/threads-technologies.html You've subsclassed QThread and use an infinite loop while expecting to receive signals. I would go for the "Worker-Thread" approach and make AudioDecoder a QObject (instead of QThread). Then create a basic QThread and move your object to the thread with moveToThread. As also used here: https://wiki.qt.io/QThreads_general_usage
  • Cannot install Qt into Raspberry Pi 4

    Unsolved
    9
    0 Votes
    9 Posts
    588 Views
    jsulmJ
    @wesee_ansul It should be the same
  • How exit a thread?

    Unsolved
    4
    0 Votes
    4 Posts
    498 Views
    C
    @nicker-player said in How exit a thread?: And the codes below seemed useless. Not that this has anything to do with Qt, but what was useless about it? If you try to std::thread::join() a thread then that thread needs to cleanly terminate while you wait. What triggers/signals that thread to terminate is entirely up to you. If you try to pthread_cancel() a native thread then how it reacts is dependent on the characteristics of that native thread. Edit: Had not seen that the threads were detached. These threads will not be joinable.
  • Yocto - run QML app on Raspberry Pi 3

    Unsolved
    19
    0 Votes
    19 Posts
    2k Views
    Ronel_qtmasterR
    @SuperMonkeyRules You're welcome
  • Unable to use QMYSQL driver on arch linux

    Unsolved
    5
    0 Votes
    5 Posts
    398 Views
    C
    @AgustinOrdonez said in Unable to use QMYSQL driver on arch linux: QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins This also looks like there is something else missing in your program. Have you created and initialised a QCoreApplication (or QApplication) in your application before attempting any database operations?
  • DISPLAY ISSUE - PROMOTING TO MAINWINDOW

    Unsolved
    14
    0 Votes
    14 Posts
    750 Views
    SGaistS
    Like I already wrote: Create a QWidget subclass Implement its paintEvent properly Set the widget as centralWidget on your QMainWindow Once you have that, you can continue further refinements.
  • Insert new dataset into QSqlTableModel

    Unsolved
    4
    0 Votes
    4 Posts
    250 Views
    MasterQM
    It is a little bit strange If you call insertRecord(-1, myrecord); in QSqlTableModel, the record is written to the database immediately, if the setting is not to submit by hand. In the datamodel a new "row"/record can be found, but this new record is fully empty. It is not filled with the data I provided by myrecord. Makes this sense? To fill the empty record in the datamodel you have to invoke submit(). Only then the new record is populated with data from the database? I do not see any sense in adding an empty record to the datamodel, when you have to call select() either. I am not sure if I do it right. Any comments? void DocumentsModel::add(QSqlRecord & record) { if(insertRecord(-1, record)) { select(); // really, no other way? auto id = getLastPrimaryKey(); auto fullpathtarget = getNewPath();; auto fullpathsource = record.value(DocumentsFieldFilename).toString(); QFile::copy(fullpathsource, fullpathtarget); auto erg = match(createIndex(0, 0), Qt::DisplayRole, id, -1); auto row = erg.first().row(); auto index = createIndex(row, fieldIndex(DocumentsFieldFilename)); setData(index, filenamenew); submit(); } } DocumentsModel is a subclass of QSqlTableModel!
  • QComboBox delegate: Best way to show the popup menu immediately?

    8
    0 Votes
    8 Posts
    8k Views
    Y
    @fanyha I had this problem too. What worked for me was calling QComboBox::showPopup from QStyledItemDelegate::eventFilter using QTimer::singleShot as follows: bool DeviceChannelAssignmentDelegate::eventFilter(QObject* src, QEvent* evt) { if (evt->type() == QEvent::FocusIn) { auto combo = qobject_cast<QComboBox*>(src); if (combo && _firstPopup) { QTimer::singleShot(0, [=]{combo->showPopup();}); _firstPopup = false; } } return QStyledItemDelegate::eventFilter(src, evt); } I set _firstPopup to true in QStyledItemDelegate::createEditor and also connect QComboBox::activated to a slot which emits DeviceChannelAssignmentDelegate::commitData and hides the QComboBox like so: QWidget* DeviceChannelAssignmentDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { auto combo = new QComboBox(parent); ... connect(combo, &QComboBox::activated, this, &DeviceChannelAssignmentDelegate::emitCommitData); _firstPopup = true; return combo; } void DeviceChannelAssignmentDelegate::emitCommitData() { auto combo = qobject_cast<QComboBox*>(sender()); emit commitData(combo); combo->hide(); } The end result is that when I double-click on item in the QTreeView, the QComboBox popup menu shows up immediately, and the QComboBox then disappears after selecting from the popup's choices which works well for me.
  • Using QDesignerContainerExtension with custom widget page

    6
    0 Votes
    6 Posts
    2k Views
    redtideR
    It took about 10 years to discover that it's not possible. :-)
  • Checking if a device has an active internet connection

    Unsolved
    23
    0 Votes
    23 Posts
    4k Views
    jsulmJ
    @RaptaG You can start with the basic example applications https://doc.qt.io/qt-6/qtexamplesandtutorials.html
  • Setting User And Password For Qt WebView & WebEngine Diectly

    Unsolved
    14
    0 Votes
    14 Posts
    3k Views
    Ronel_qtmasterR
    you can also check this as well https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/qml/networkaccessmanagerfactory?h=5.15
  • qt.qpa.xcb: could not connect to display ?

    Unsolved
    3
    0 Votes
    3 Posts
    521 Views
    Ronel_qtmasterR
    @_APM_ it is simple run it directly from the target board and it will work
  • Ethernet Port Disable

    Unsolved
    3
    0 Votes
    3 Posts
    269 Views
    SGaistS
    Hi, In addition to @jsulm, this is an administrative task that will require higher privilege than a standard user. The most likely way to do it would be using QProcess to run the tools however, you will have to somehow get higher level access for that to work.
  • how to use zxcvbn-c library in qt5 on windows 11

    Unsolved
    2
    0 Votes
    2 Posts
    226 Views
    SGaistS
    Hi, If you are talking about this project, the README suggests to include the code directly in your application. Note that the CMakeLists.txt they provide serves also as an example on how to integrate it or build it as a library.
  • QTextEdit resizing

    Unsolved
    2
    0 Votes
    2 Posts
    253 Views
    SGaistS
    Hi and welcome to devnet, One thing you can do is get the size of the underlying QTextDocument and modify the size of your QTextEdit accordingly.
  • MySQL problem with inserting quote in my QSqlQuery prepare statement

    Solved qsqlquery qstring quotes
    20
    0 Votes
    20 Posts
    2k Views
    JonBJ
    @swankster :) Like I said, just build the (correct, including whatever quoting, and if you are OK on possible SQL injection attacks!) string and pass that without using binding, for this query.
  • android/build.gradle

    Unsolved
    4
    0 Votes
    4 Posts
    468 Views
    JoeCFDJ
    @Jean-MARTINON Quite some discussions have been made about Android build in this forum. Try to find these topics first. Also what are your OS and Qt Version? What have you done?
  • Calling QCoreApplication::processEvents from QtTest appears not to work

    Solved
    2
    0 Votes
    2 Posts
    370 Views
    V
    Yes - using QTEST_GUILESS_MAIN(TestLogging) rather than QTEST_APPLESS_MAIN does help to provide an event loop :-D
  • How to change the style of tree item drop.

    Unsolved
    1
    0 Votes
    1 Posts
    128 Views
    No one has replied