Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.0k Posts
  • How to add a new language layout to Qt Virtual Keyboard?

    Unsolved
    5
    0 Votes
    5 Posts
    766 Views
    U
    @Pl45m4 . @SGaist Hi, Thank you for sharing info. I have made some progress in adding a new layout (en_JP) to the Qt Virtual Keyboard (QVK), but I am still facing challenges in fully resolving the issue. Below is the current status: Steps Taken Created layout folder and files • Added necessary files (e.g., main.qml) under the directory: qtvirtualkeyboard/src/virtualkeyboard/content/layouts/en_JP/. Registered the layout in the .pro file • Added the following configuration to virtualkeyboard.pro to include the custom layout in the build: contains(CONFIG, lang-en(_JP)?) { LAYOUT_FILES += \ content/layouts/en_JP/dialpad.fallback \ content/layouts/en_JP/digits.fallback \ content/layouts/en_JP/main.qml \ content/layouts/en_JP/numbers.fallback \ content/layouts/en_JP/symbols.fallback } Build configuration • Updated Qt/5.12.12/Src/qtvirtualkeyboard/src/config.pri to include all languages in the build: CONFIG += lang_all Build and verification • Built the module and confirmed that the new language appears in the list of available languages in QVK. • Verified that the custom layout is displayed correctly when the new appeared language is selected. Current Issue While the new language (en_JP) is successfully added, the displayed language name still defaults to “English America”. I want it to show “English Japanese” in the following places: • The language selection menu (accessed via the globe icon). • Above the spacebar on the keyboard. Attempts So Far • I suspect that setting the correct locale is necessary, but I could not find any concrete information or clues about how to proceed. Questions 1. What steps are required to display the language name as “English Japanese”? 2. Are there specific files or code that need to be modified to set the correct language name and locale? 3. If Qt Virtual Keyboard determines the display name automatically based on the language code (en_JP), how can this behavior be customized? Your guidance on resolving this issue would be greatly appreciated. Thank you!
  • 0 Votes
    4 Posts
    384 Views
    l3u_L
    Actually, this does help … but it does not really fix it, depending on the font size used … On my notebook, I have a 14" screen and thus use a bigger font (we're all not 20 anymore, are we?! ;-) However, this is what I get there: [image: 27ba4570-366c-4f35-9131-4fac1e897d0d.png] So, due to the bigger font, I still get that "smaller but still usable" top-bottom compression. When I resize the dialog, the widgets grow to the size they should have, but they won't grow larger: [image: 77207f63-2c16-4268-81b4-7fa01b59c771.png] So, we're back to the initial question … Despite QSizePolicy::Fixed set for the vertical size, the widget can shrink a bit smaller, causing this "small but still usable" compression for the combo and spin boxes – and clipping the label texts that contain line breaks. No matter what I do, I can't seem to prevent the clipping. Also doing setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed) on each and every widget within the box does not change anything – I can still clip the label text and still "compress" the combo and spin boxes. What I also tried is to play with size constraints. When I do setSizeConstraint(QLayout::SetMinimumSize) on the box's layout, then the following happens: [image: 631071d2-0942-4b3a-b84d-f9f59c54c2fb.png] The compression and clipping is gone – but now, the whole box is clipped instead :-( Resizing the dialog makes it visible again, and it also does not grow larger than the actually needed vertical size. But somehow, the layout thinks it does not need this space … either, it lacks inside the box, or outside of it …
  • Bring slider to mouse click position.

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    P
    Hi, I just solved the same problem using a normal QSlider and its "actionTriggered(int action)" signal. There are the actions "SliderPageStepAdd" and "SliderPageStepSub" that are triggered when I click on the track. void MainWindow::on_horizontalSliderSeek_actionTriggered(int action) { if(action == QAbstractSlider::SliderPageStepAdd || action == QAbstractSlider::SliderPageStepSub){ QPoint Mouse = ui->horizontalSliderSeek->mapFromGlobal(QCursor::pos()); QSize Size = ui->horizontalSliderSeek->size(); int max = ui->horizontalSliderSeek->maximum(); int position = (Mouse.rx()*max)/qMax(Size.width(),1); ui->horizontalSliderSeek->setValue(position); QMplayer.setPosition((QMplayer.duration()*position+(max/2))/max); } } void MainWindow::on_horizontalSliderSeek_sliderMoved(int position) { int max = ui->horizontalSliderSeek->maximum(); QMplayer.setPosition((QMplayer.duration()*position+(max/2))/max); } I use the "sliderMoved" signal to handle movement using the knob. I also tried checking for the "SliderMove" action in the "actionTriggered(int action)" signal. But somehow the "sliderMoved" signal is triggered more often and seeking in the movie this way just feels a little more smooth. The "qMax(Size.width(),1)" is just to prevent a division by 0 if for some reason the Size.width returns 0.
  • Plugin derived from QGeoServiceProviderFactory gives linker errors

    Solved
    9
    0 Votes
    9 Posts
    5k Views
    DuBuD
    Now it works! If I add the Location library to find_package and target_link_libraries, I'm able to build my plugin as a SHARED library and my app loads it as well.
  • Why the process memory continouly increase

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    Pl45m4P
    @BernardZhu said in Why the process memory continouly increase: If you don't read all the data at once, the remaining data will still be available later, and any new incoming data will be appended to QAbstractSocket's internal read buffer. To limit the size of the read buffer, call setReadBufferSize(). Good to hear that you've figured it out. You can mark your own answer as the solution :)
  • Leveraging Qt models for nested data structures

    Unsolved model qabstractlistmo
    5
    0 Votes
    5 Posts
    3k Views
    E
    Like in your example as of now I think I'd make one tree model. I had considered creating a tree model, but I have some reservations. Store, Department, and Employee have additional responsibilities beyond being simple data containers, and I worry that either I end up decoupling the data from the logic (which goes against OOP principles), or I have to subclass the three classes from a common class, override functions, and therefore haven't achieved clear separation of UI and business logic. To my mind at least, it makes sense to design this as if it were a command line application, and then throw some code on top to interface with a GUI. Maybe that's not the right way to think about things, but I don't like the idea of the GUI framework I'm using dictating how I should structure my data. Aren't you describing a use case for a database and thus Qt's SQL module and its models ? Truthfully, the application has nothing to do with stores, departments, or employees. I changed the names to make the problem easier to reason with. I don't think the data layout is so complex that it justifies introducing relational databases. And besides, with the very frequent live updates coming over the network I can see latency issues arising.
  • QTcpSocket::waitForReadyRead continually reserved lots of memory

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    Christian EhrlicherC
    Use signals and slots instead a blocking call. Then you also don't need a separate thread.
  • 0 Votes
    5 Posts
    2k Views
    JonBJ
    @YJMForgive said in What's the most efficient way to update QListWidget when QLineEdit changes - filtering and restoring items in Qt?: , I want to filter items in a QListWidget based on what the user types in a QLineEdit. When users type in the QLineEdit, the QListWidget should show only matching items. Users should still be able to click on any visible list item to trigger corresponding events. It's just that this is exactly what QCompleter does, on a list in a popup rather than in a QLisWidget. And you can react on user clicking an item in the filtered list. Anyway, accepting that QCompleter is not what you want for whatever reason, it uses the approach of a model and a filter in the same way as described in @Pl45m4's suggestion. So you should follow that.
  • QPrintDialog preview on Windows

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    Z
    @Pl45m4 Thanks for the reply. QPrintPreviewDialog seems redundant based on my testing. For example, the page orientation selected on the preview dialog does not get passed to to the native Windows print dialog. The "print" toolbar button also brings up the native Windows print dialog with preview anyway. Because of this, I was hoping there was a Windows API that someone else had found similar to the paintRequested signal of QPrintPreviewDialog that would allow the preview to be directly shown on the QPrintDialog. https://doc.qt.io/qt-6/qprintpreviewdialog.html#paintRequested [image: bf49ea1c-1928-41bd-b031-4216ab96f59f.png]
  • Connection signals for dynamically created widgets

    Solved c++ signal & slot desktop
    11
    0 Votes
    11 Posts
    3k Views
    D
    @JonB said in Connection signals for dynamically created widgets: Bit it does not! QGraphicsItems do not inherit QObject, only QGraphicsObjects do. You're right! I got confused when going up the inheritance tree in the documentation, I clicked on "inherited by QGraphicsObject" at some point thinking it was "inherits" instead. I didn't specify in a written manner that my StateWidget was a QGraphicsEllipseItem as I had added the declaration of the class in the first message. I changed the class to inherit QObject as well though and it worked! class StateWidget : public QObject, public QGraphicsEllipseItem { ... } The order of inheritance is important too. The "Test n" below comes from the AutomatLab::StateParams function so the signal is properly forwarded to the main UI instance! [image: 973931d7-e484-4597-8d82-5c6be4cefda8.png] Thank you for your help!
  • query.execBatch() does nothing

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    SavizS
    @Christian-Ehrlicher I agree. I think it is better to be explicit and convert to correct data types so that the driver does not complain. Here is the corrected code and it works: QVariantList patientIDs; QVariantList treatmentIDs; for (const QVariant &item : newTreatments) { patientIDs.append(m_PatientDataMap["patient_id"].toULongLong()); treatmentIDs.append(item.toULongLong()); } queryInsert.addBindValue(patientIDs); queryInsert.addBindValue(treatmentIDs); Thank you for your help.
  • Crash on menuBar() after setMenuWidget()

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    Christian EhrlicherC
    @Paddle said in Crash on menuBar() after setMenuWidget(): QMenuBar* menuBar = getMainWindow()->menuBar(); Use a debugger and see where it crashes. Since getMainWindow() is your own function I would guess it returns a nullptr.
  • How to add custom delimited completion to QLineEdit using QCompleter ?

    Unsolved
    5
    0 Votes
    5 Posts
    3k Views
    D
    Okay, now I have got something to work with a custom QWidget and QListWidget. I am showing the QWidget as a popup whenever I need it to show suggestions on a QLineEdit. Only issue now is that the QLineEdit blinking cursor doesn't show up whenever the popup is open. I have changed the FocusPolicy of the popup widget but still no luck. Is there any way to get the cursor back to the QLineEdit ?
  • Best app object hierarchy pattern for QUndoStack/QUndoCommand

    Unsolved
    2
    0 Votes
    2 Posts
    476 Views
    SGaistS
    Hi, The answer depends partly on what your application does. For example, a text editor will have an undo stack per document. Same for a painting application. Taking the painting application example, would you need one global stack for the document or one per tool you are using ? Both. There's no single universal answer to your question as it depends highly about the operations you are doing, how far does undoing go, etc.
  • qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    jsulmJ
    @K-a-r-l-l-z-y Please provide more information: how did you deploy your app? On Windows you should use https://doc.qt.io/qt-6/windows-deployment.html
  • i have a error in my coding please help me to resolve

    Unsolved
    10
    0 Votes
    10 Posts
    4k Views
    SGaistS
    @muhammad15 On the importance of naming things correctly and using typing in Python: preview_dialog.paintRequested.connect(custom_print) The paintRequested signal has a QPrinter parameter not a QPainter. So declaring def custom_print(printer: QPrinter): Would have already helped you understand where your issue came from.
  • Qt WebEngine running on Windows11 with Touch screen crashed

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    C
    I solved the problem by using the import QtWebEngine.ControlsDelegates in the main.qml. This also creates the directory .\qml\QtWebEngine\ControlsDelegates during the build. This directory contains the QML modules TouchHandle.qml and TouchSelectionMenu.qml. This prevents the application from crashing.
  • convert cv::Mat into QPixmap

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    BondrusiekB
    @JacobNovitsky hi, you can see also this article: https://asmaloney.com/2013/11/code/converting-between-cvmat-and-qimage-or-qpixmap/ maybe it helps you.
  • How to automatically maximize a subWindw in a QMdiArea

    Unsolved
    2
    0 Votes
    2 Posts
    794 Views
    JonBJ
    @Audetto https://www.qtcentre.org/threads/41101-QMdiArea-and-adding-sub-window try using setWindowState(Qt::WindowMaximized) on the sub window instance it self : m_mdiArea->addSubWindow(Editor)->setWindowState(Qt::WindowMaximized) ; That worked in Qt in 2006, so I imagine it's the same two decades later...? :)
  • is Qt Widgets Designer the same as Qt Designer?

    Solved qtdesigner qtcreator
    2
    0 Votes
    2 Posts
    392 Views
    C
    Effectively, yes. Your linked page is referring to an embedded version of the standalone Qt Designer application present in Qt Creator as "Qt Widgets Designer". They both produce .ui files describing a UI.