Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.3k Topics 455.6k Posts
  • How to write a data into csv file colmn by column

    Unsolved 20 Aug 2023, 11:31
    0 Votes
    2 Posts
    173 Views
    @swapna-v There isn't much to say. Build each line output as comma-separated values from the columns.in a loop. No reason for it to stop at 2 columns, and nobody can say why you say "printing continuously". Your output seems to show you are saving columns as multiple lines. You don't show your produced CSV file, you don't show the code you write.
  • Qopenglbuffer - 64 bit addressing?

    Solved 15 Aug 2023, 20:49
    0 Votes
    7 Posts
    509 Views
    AFAIK, most if not all games adapt the level of details based on the zoom factor because there's no sense in calculating all the details of the grass at the limit of the forest located 2km away from you. But it start making sense when you are close to it.
  • Failed to find required Qt component "Core5Compat".

    Unsolved 20 Aug 2023, 11:56
    0 Votes
    2 Posts
    262 Views
    Do you mean this one: [image: c23540ce-d527-463b-b3d9-21a89d2af560.png]
  • Bug in QImage

    Solved 17 Aug 2023, 12:01
    0 Votes
    10 Posts
    619 Views
    @wostka said in Bug in QImage: Not a bug, a feature... :D No feature but a mandatory thing - otherwise there is no reference to the resource and the lnker can throw it away.
  • 0 Votes
    4 Posts
    232 Views
    @bogong The forum topic is from 2010. I don't see anything "6.x" about that or concerning a signal, but never mind, it's the right thing to use.
  • Scroll Bar diretion for RTL languarges

    Unsolved 19 Aug 2023, 16:21
    0 Votes
    9 Posts
    727 Views
    @Volker-D said in Scroll Bar diretion for RTL languarges: Thank you! It was pure luck this time - the reason was easy to find :) I'll take a look into the other one if I find some time.
  • Can I open Qt project with Ubuntu cmd

    Solved 20 Aug 2023, 03:03
    0 Votes
    2 Posts
    112 Views
    @JacobNovitsky # System Qt Creator qtcreator workspace/simple_example/simple_example.pro # Local Qt installed by online installer ~/Qt/Tools/QtCreator/bin/qtcreator workspace/simple_example/simple_example.pro Adjust the paths to suit.
  • qt call ocx

    Unsolved 15 Aug 2023, 04:58
    0 Votes
    8 Posts
    498 Views
    @JonB Thanks. I'm going to try the queryInterface() function.
  • valgrind in qtcreator crashed

    Unsolved 25 Apr 2019, 09:35
    0 Votes
    12 Posts
    2k Views
    @Zekses Thank you. Really helpful! ❤️ It saved me for my software verification student project!
  • 0 Votes
    3 Posts
    460 Views
    Remove space; Inside the table cell but outside my custom widget Here some code snap. @ChrisW67 #include "ElementsListWidget.h" #include "AbstractElement.h" #include "ElementDragEventHandler.h" #include <QAbstractScrollArea> #include <QGridLayout> #include <QLabel> #include <QPixmap> #include <QScrollArea> #include <QSortFilterProxyModel> #include <QVariant> #include <qscrollbar.h> #include <qstandarditemmodel.h> #include <qtreeview.h> ElementsListWidget::ElementsListWidget(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainlayout = new QVBoxLayout(this); mainlayout->setContentsMargins(0, 0, 0, 0); elementsListLayout = new QTreeView(this); elementsListLayout->setContentsMargins(0, 0, 0, 0); elementsListLayout->setHeaderHidden(true); elementsListLayout->setIndentation(0); elementsListLayout->setUniformRowHeights(false); elementsListLayout->setObjectName("ElementsListWidget"); elementsListLayout->setSelectionMode(QAbstractItemView::NoSelection); elementsListLayout->verticalScrollBar()->parent()->setProperty("background_transparent", true); elementsListLayout->horizontalScrollBar()->parent()->setProperty("background_transparent", true); sourceModel = new QStandardItemModel(this); elementsListLayout->setModel(sourceModel); mainlayout->addWidget(elementsListLayout); setLayout(mainlayout); elementsPerRow = 3; totalModelElements = 0; sourceModel->setColumnCount(elementsPerRow); } void ElementsListWidget::addElement(AbstractElement* element) { elementsModel << element; showWidgetOnView(createDisplayUnit(element)); } QWidget* ElementsListWidget::createDisplayUnit(AbstractElement* element) { if (!element) { return nullptr; } QWidget* elementDispalyWidget = new QWidget; elementDispalyWidget->setObjectName("elementDisplayUnit"); QVBoxLayout* elementdisplayLay = new QVBoxLayout(elementDispalyWidget); //elementdisplayLay->setContentsMargins(0, 0, 0, 0); QLabel* elementIconLabel = new QLabel(elementDispalyWidget); elementIconLabel->setObjectName("elementIconLabel"); elementIconLabel->setProperty("element", QVariant::fromValue(static_cast<AbstractElement*>(element))); elementIconLabel->setCursor(Qt::OpenHandCursor); elementIconLabel->setAlignment(Qt::AlignCenter); elementIconLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); elementIconLabel->installEventFilter(new ElementDragEventHandler(elementIconLabel)); // Install event filter elementIconLabel->setPixmap(element->getImage().scaled(50, 50)); QLabel* elementNameLabel = new QLabel(element->getName(), elementDispalyWidget); elementNameLabel->setObjectName("elementNameLabel"); elementNameLabel->setAlignment(Qt::AlignCenter); elementNameLabel->setWordWrap(true); elementdisplayLay->setAlignment(Qt::AlignHCenter); elementdisplayLay->addWidget(elementIconLabel); elementdisplayLay->addWidget(elementNameLabel); elementdisplayLay->addStretch(); elementDispalyWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); return elementDispalyWidget; } void ElementsListWidget::setElementsPerRow(int numberOfelementsPerRow) { if (numberOfelementsPerRow > 0) { elementsPerRow = numberOfelementsPerRow; } } void ElementsListWidget::serachElement(const QString& searchText) { clearModel(); // Iterate through the stored widgets in elementWidgetModel for (AbstractElement* element : elementsModel) { if (element && element->getName().contains(searchText, Qt::CaseInsensitive)) { showWidgetOnView(createDisplayUnit(element)); } } } void ElementsListWidget::showWidgetOnView(QWidget* elementDisplayUnit) { if (elementDisplayUnit == nullptr) { return; } QStandardItem* item = new QStandardItem; // Calculate the row and column count for the new element int row = totalModelElements / elementsPerRow; int column = totalModelElements % elementsPerRow; sourceModel->setItem(row, column, item); elementsListLayout->setIndexWidget(item->index(), elementDisplayUnit); totalModelElements++; } void ElementsListWidget::clearModel() { sourceModel->clear(); totalModelElements = 0; } styel sheet for few widget QWidget#ElementsListWidget { background-color: #DAE0E9; color: #3B5571; border: none; } #elementDisplayUnit { background-color: transparent; font-size: 14px; } #elementIconLabel { width: 64px; background-color: #ffffff; border: 1px solid #BEC9CD; height: 64px; position: relative; /* align-items: center; */ border-radius: 5px; /* justify-content: center; */ background-color: #FFFFFF; } #elementIconLabel:hover { background-color: lightgray; } #elementNameLabel { padding: 0px 0 0 0; font-size: 11px; max-width: 64px; text-align: center; line-height: 12px; /* text-overflow: ellipsis; */ background-color: transparent; /* word-wrap: break-word; */ font-weight: bold; }
  • bidirectional property binding

    Solved 18 Aug 2023, 08:48
    0 Votes
    3 Posts
    305 Views
    Hi, One way to implement what you want is to create a simple event filter and check for QShowEvent and QHideEvent for the widgets of interest and change the visible property of the other widgets accordingly.
  • CMakeLists issue

    Unsolved 18 Aug 2023, 12:36
    0 Votes
    11 Posts
    8k Views
    If you have installed Qt Creator standalone you need to tell it where to find Qt. Under Preferences -> Kits -> Qt Versions click on Link with Qt... and then restart. Afterwards you should be set, and your CMakeLists.txt projects do not need any set(CMAKE_PREFIX_PATH ...) entries. Usually it's bad practice to do such things. A project needs to be configured from "outside".
  • QTreeWidget: dropping item between other items

    Unsolved 18 Aug 2023, 17:54
    0 Votes
    2 Posts
    173 Views
    Hi, One thing that comes to mind is the use of the position of the drop event to determine whether you have a cell under the cursor.
  • Are lambda signals and slots handled by moc

    Solved 18 Aug 2023, 16:04
    0 Votes
    7 Posts
    391 Views
    @Christian-Ehrlicher Your https://doc.qt.io/qt-6/metaobjects.html listed: In addition to providing the signals and slots mechanism for communication between objects (the main reason for introducing the system), the meta-object code provides the following additional features: QObject::tr() translates strings for internationalization.
  • Hamburger Menu for Qt Widgets? Please share it

    Solved 22 Sept 2018, 21:21
    0 Votes
    4 Posts
    2k Views
    @Agron check this https://www.youtube.com/watch?v=TxZO5AvC0NI
  • Touchscreen right click in QtWidget app

    Unsolved 18 Aug 2023, 07:44
    0 Votes
    3 Posts
    293 Views
    @Pl45m4 I use qt 5.15.3 and I don;t use QML/QtQuic
  • passing a parameter to a method causes Window to freeze

    Unsolved 17 Aug 2023, 09:09
    0 Votes
    10 Posts
    672 Views
    @jsulm Hi and Good question. So, at the top of my Worker() class, I have: result = pyqtSignal(str) # Signal emitted after each function with the result and then later on in my Main() class I have: self.worker.result.connect(self.update_text_browser) this is the update_text_browser function: def update_text_browser(self, result): self.textBrowser.insertHtml('<p align="left"><font face="Arial" color="black" size=3 ><b>'+ result + '</b></font><br></p>') I'm assuming that all of this allows the emitted result to be displayed in my text_browser? 'result' is obviously successfully emitting to 'text_browser', but yes and weirdly, around the 4th or 5th emit the Window seems to hang... what could be the cause? As for using debugger, are you referring to pdb? I tried implementing it, but it didn't seem to work unless I ran it from the Main() class (as opposed to Worker()), but running it from Main() resulted in an infinite loop and not the function itself running. I will try again, unless you are referring to another debugger specific to pyqt? Thank you,
  • Show virtual keyboard

    Unsolved 2 Mar 2019, 05:38
    0 Votes
    5 Posts
    617 Views
    let me refresh the topic instead of creating a new one as I have the same question. I deployed ubuntu 22.04 onto a RPI4. There is already a virtual keyboard in standard Gnome session and works with the Ubuntu stock apps (GTK I assume) When I load my project and click in my QLineEdit nothing happens. Of course I can load qvirtualkeyboard by adding #ifndef Q_OS_WIN qputenv("QT_QPA_PLATFORM", "xcb"); qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); #endif but then it is not consistent with the whole desktop. Is it possible to make Qt app to use standard gnome Virtual Keyboard?
  • 0 Votes
    1 Posts
    179 Views
    No one has replied
  • Three-click

    Unsolved 16 Aug 2023, 18:45
    0 Votes
    5 Posts
    477 Views
    @AndrzejB said in Three-click: Will no conflict with standard QWidget:: mouseDoubleClickEvent? Yes, and the double click event will always conflict with the single click. However, the double click can only occur (and thus will be handled) after the single click. In the same way the triple click can only occur after the double click. Somewhere in the back of my mind I remember that there is a GUI guideline stating that a double click should not do something totally unrelated to the single click as to not confuse users. The first click positions the cursor; the second click selects the word under the current cursor; the third click would now select the whole line (which will contain the currently selected word). Every click is thus an extension of the previous one. There will be no problem in first handling the single click, after that the double click, and finally the triple click. Otherwise you will have to delay the action of the click using a QTimer and some boolean variables to check if the single wasn't overridden with a double click and the double click wasn't overridden with a triple click.