Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
82.7k Topics 452.2k Posts
  • 0 Votes
    2 Posts
    86 Views
    Pl45m4P

    @Deckhead said in How do manage a large data structure manipulated by tonnes of widgets, with logic applied throughout:

    I looked at Model/View, but I can't see that this is what I want. Or if it is I don't see how it would work

    Not sure if I understood everything above but this sounds like a case for a proper data model.
    One model to hold all the information and then you have multiple widget across your app to modify bits of it...
    And to update you just have to make sure the model/view/editor is consistent. No need to manually tell 100 widgets that option X has changed if they all refer to the same data

  • QML Resize Jitter

    Unsolved
    2
    0 Votes
    2 Posts
    69 Views
    JoeCFDJ

    Better to tell your OS and add more code for other people to test it.

  • Change icons in columns on QTreeWidget

    Unsolved
    9
    0 Votes
    9 Posts
    487 Views
    JonBJ

    @Bonnie said in Change icons in columns on QTreeWidget:

    @gabello306 Why do you need column for itemExpanded?
    It is not provided because Expanded/Collapsed is for the whole row, not one single column.

    That is exactly what I asked earlier. Those signals which need/work on a column have it as a parameter. Expand/collapse is by row, not by column, hence does not. I too do not understand what OP wants column for: when you click on an "arrow" it does not matter, and should not matter, what column that is in, just the row it is on, which you get for the QTreeWidgetItem.

    Does QFileSystemModel (with a QTreeView) do whatever it is you want about opening/closing folder icons?

    I (perhaps like @Bonnie) am unclear how you are handling these "expansion" items. You are supposed to do this via QTreeWidgetItem::setIcon(), setting the inbuilt icon for the whole QTreeWidgetItem. You don't care what column/indent level/depth this appears at, Qt handles that for you. But the way you mention "four columns", and want to get a column index, might imply you are handling the expansion icons as their own column yourself? We do not have information to know. If you are doing the first, intended way then it seems to me the code at https://stackoverflow.com/a/46834929/489865 shows you how to handle the itemExpanded/Collapsed signals to change the QTreeWidgetItem's icon without any reference to column number.

    I would recommend the foregoing. If you really, really want to handle icons on your own columns then you need to know the depth of the QTreeWidgetItem received as parameter to itemExpanded/Collapsed slot. Since I do not see any method on QTreeWidgetItem or QTreeWidget to return this, you can loop upwards off QTreeWidgetItem::parent() until that returns nullptr (top-level item). The number of iterations is the depth of the item, and that is the column where your indicator icon lives.

  • Performance of QPainter?

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    A

    @Kamajii said in Performance of QPainter?:

    I was musing about the current (future) situation of QPainter , and whether I should use it as the principal painting engine for a new graphics-intense project

    No
    QPainter has terrible performance on some use cases (like multi-pixel width cosmetic pens)

    @Kamajii said in Performance of QPainter?:

    It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.

    That's right. QPainter is going to stay in a stable state, but don't expect any improvements.

    @Kamajii said in Performance of QPainter?:

    So I suppose what eventually will/should happen is that QPainter also gets an RHI backend.

    I don't see that happening like, ever.

    I have made the transition from QGraphicsView (which uses QPainter) to QtQuick a few years ago, and I haven't looked back. You can get really great performance by building a QML scene with custom-drawn, C++-written QQuickItems.

    EDIT: I should add that the documentation for writing QQuickItems in C++ using SceneGraph is...lacking. There are a few blog posts by KDAB to help, if I remember correctly.

  • QT 6.7.2 C++ delete symblic link

    Unsolved
    4
    0 Votes
    4 Posts
    153 Views
    SGaistS

    @dheerajshenoy what is your exact situation ?
    What does QDir::remove tell you ?

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    8 Posts
    6k Views
    pillexyz_zP

    I don't know why it's hard to understand that it shouldn't register ALT-GR as CTRL+ALT just register it simply ALT or a different type of ALT but not CTRL+ALT (or atleast put an option there).

  • 0 Votes
    4 Posts
    107 Views
    Pl45m4P

    @dano said in QTabWidget with bottom left rounded tabs & rotated icon + text:

    QListWidget thing.

    I don't see why you need a QListWidget there.
    Just a QStackedWidget for the content and the sidebar widget with buttons on the left to select the right page.

  • 0 Votes
    4 Posts
    155 Views
    Pl45m4P

    @Wintermute said in Detecting system tray background color:

    (this is Flowkeeper, fwiw)

    This is great :)
    I could have used this during my studies, as most time/task planners and ToDo tools are crap :D

  • 0 Votes
    7 Posts
    263 Views
    G

    I see, thanks for explaining.

  • 0 Votes
    1 Posts
    52 Views
    No one has replied
  • 0 Votes
    2 Posts
    62 Views
    Christian EhrlicherC

    Please show your CMakeLists.txt. Did you enable CMAKE_AUTORCC?

  • 0 Votes
    7 Posts
    230 Views
    JonBJ

    @GabrielBruce
    What's to be excited about and what more do you want to learn? :) QVariant() returns a default, invalid QVariant, and you can e.g. pass that as a bound value where you would use NULL in SQL.

  • 0 Votes
    13 Posts
    493 Views
    A

    Thanks to @JonB for always take part on my complicated, unusual problems and questions and for helping me.
    I really appreciate it!

    this is how the application look like now
    image.png

    soon I'll post the full code on my github at https://github.com/aVenturelli-qt so anyone interested in it can take a look.

  • How to add a new language layout to Qt Virtual Keyboard?

    Unsolved
    5
    0 Votes
    5 Posts
    321 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
    187 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:
    1.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:
    2.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:
    3.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
    898 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.

  • 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 :)

  • 0 Votes
    5 Posts
    2k 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.