Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Do I need to call installEventFilter(this)?

    Solved
    6
    0 Votes
    6 Posts
    676 Views
    JonBJ
    @JobRecrd No, installEventFilter sends the events to the eventFilter in the first place. From there you can optionally handle them, or you can just use it to choose to ignore some events while allowing others through for standard processing.
  • How do you center QGraphicsTextItem in its parent?

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    D
    For the text alignment, this setY ... text->setY(ellipse->boundingRect().center().y() - text->boundingRect().height()/2); scene()->addItem(ellipse); in void PieView::onMouseOver(PieSeries &s) works: [image: e0c7013d-421e-4567-9059-f36861b238b4.gif] Still couldn't figure out why the remaining slices moves once or more when I first start hovering over slices
  • How to use Signals & Slots to make Inter-Process Communication in Qt ?

    Unsolved
    12
    0 Votes
    12 Posts
    3k Views
    A
    @artwaw thank you for your answers , i know, maybe , i can to do what i want to do with TCP/IP, but i need certainly more and more of time to do it , I thought that Qt D-Bus will win me time, since we have a lot of class Q D-Bus , who can do the work Sincerely, it's the loss of not using so many courses on Windows.
  • How to generate multiple queries

    Unsolved
    5
    0 Votes
    5 Posts
    414 Views
    JonBJ
    @LT-K101 Yes, that is just a UI detail. There is no problem here other than you explaining what these "25 queries" are all about, what exactly you are trying to do/ask.
  • Layout scratching head...

    Unsolved
    21
    0 Votes
    21 Posts
    2k Views
    SPlattenS
    @mchinand , this might look a bit over the top, I have a class clsQtLayout which is derived from QWidget, the reason for this is because the class supports layouts with a scrollable area which can only be accommodated by using a widget to contain everything. After much work the QVBoxLayout works great, I have a form layout inside that can have a fixed height and in my example contains radio buttons, it can be scrollable within the vertical layout. I have tried the same techniques for the QHBoxLayout and this is where I'm having problems, for some reason which I'm not seeing it just doesn't work. Going back to my XML: <layout type="form" height="72" hspacing="0"> <buttongroup id="enSEX" dbfield="vcSex"/> <radiobutton id="rdoM" group="enSEX" text="Male" default="true" position="0,0"/> <radiobutton id="rdoF" group="enSEX" text="Female" position="1,0"/> </layout> This XML behind the scenes creates a QVBoxLayout because the height of the required QFormLayout has a fixed height. A QWidget is created which the QScrollArea connected to. The QScrollArea is then connected to the QVBoxLayout. if ( intFixedHeight > 0 ) { //Create a vertical layout as the container for this layout pobjVBox = new QVBoxLayout; //Create and set-up scroll area mpobjScroller = new QScrollArea; mpobjScroller->setWidget(pobjContainer); mpobjScroller->setFixedHeight(intFixedHeight); pobjVBox->addWidget(mpobjScroller); } pobjLayout = new QFormLayout; //Set-up form pobjLayout->setContentsMargins(0,0,0,0); pobjLayout->setSpacing(0); QString strHorzSpacing(mpobjNode->strGetAttribute( clsXMLnode::mscszAttrSpacingH)); if ( strHorzSpacing.isEmpty() != true ) { ((QFormLayout*)pobjLayout)->setHorizontalSpacing(strHorzSpacing.toInt()); } if ( pobjContainer != nullptr ) { pobjContainer->setLayout(pobjLayout); } This all works fine, the following XML is for the horizontal layout: <layout id="btnbarLO" type="horizontal" width="128"> <groupbox id="btnbar" layout="btnbarLO" properties="background-color:#ff0000;"/> <button id="btnApply" group="btnbar" api="applyChanges"> <subscriber signal="clicked" target="simon2.js@applyButton"/> </button> <button id="btnUndo" group="btnbar" api="undoChanges"/> <button id="btnOK" group="btnbar" api="submitAndClose"/> </layout> And the code in the layout class for this, which should be very similar to the vertical layout: if ( intFixedWidth > 0 ) { //Create a vertical layout as the container for this layout pobjHBox = new QHBoxLayout; //Create and set-up scroll area mpobjScroller = new QScrollArea; mpobjScroller->setWidget(pobjContainer); mpobjScroller->setFixedWidth(intFixedWidth); pobjHBox->addWidget(mpobjScroller); } pobjLayout = new QHBoxLayout; //Set-up form pobjLayout->setContentsMargins(0,0,0,0); pobjLayout->setSpacing(0); QString strHorzSpacing(mpobjNode->strGetAttribute( clsXMLnode::mscszAttrSpacingH)); if ( strHorzSpacing.isEmpty() != true ) { ((QHBoxLayout*)pobjLayout)->addSpacing(strHorzSpacing.toInt()); } if ( pobjContainer != nullptr ) { pobjContainer->setLayout(pobjLayout); } However this isn't working and the results are as shown in the original screenshot: [image: 90103c88-c687-4459-883b-84d414bc1e2e.png] I've set the background colour of the QGroupBox to red to clarify where it is. [edit] I can see it isn't clear, so elsewhere in my node handling code there is this logic where nodes are appended to parent nodes: QWidget* pobjWChild(pobjChild->pobjGetWidget()); if ( pobjWChild != nullptr && mstrName.compare(clsXMLnode::mscszNodeLayout) == 0 ) { //Yes, does the parent have a layout? QLayout* pobjLayout(pobjGetLayout()); if ( pobjLayout != nullptr ) { QString strType(strGetAttribute(clsXMLnode::mscszAttrType)); QFormLayout* pobjForm(qobject_cast<QFormLayout*>(pobjLayout)); //Add the widget for the layout if ( pobjForm != nullptr && strType.compare(clsXMLnode::mscszLayoutVertical) == 0 ) { pobjForm->addRow(pobjWChild); } else { pobjLayout->addWidget(pobjWChild); } } }
  • Preview forms before saving into database

    Unsolved
    9
    0 Votes
    9 Posts
    570 Views
    L
    @SGaist thanks
  • Transparent window has different behavior between Linux platform and Windows platform?

    Unsolved
    10
    0 Votes
    10 Posts
    687 Views
    S
    Qt has a feature for this, i.e. masking of widgets. Have a look at their shaped clock example: https://doc.qt.io/qt-5/qtwidgets-widgets-shapedclock-example.html
  • QT program crashing when using the extern keyword on a global object

    Unsolved
    16
    0 Votes
    16 Posts
    1k Views
    Christian EhrlicherC
    @JonB said in QT program crashing when using the extern keyword on a global object: This may or may not be a good way to design your software This is no question - the design is bad (the nicest word I could find for it, sorry)
  • Interfaces must inherit QObject?!

    Solved
    24
    0 Votes
    24 Posts
    5k Views
    JonBJ
    @JKSH said in Interfaces must inherit QObject?!: OP forgot to re-run qmake (or delete the build directory) after making ICake inherit QObject and adding the Q_OBJECT macro. They can't. Thank you, this makes a lot more sense then!
  • move photo from right to left on widget

    Solved
    12
    0 Votes
    12 Posts
    930 Views
    C
    @JoeCFD Thank you for your help
  • StyleSheet for custom widget inherited from `QSlider`

    Unsolved
    1
    0 Votes
    1 Posts
    250 Views
    No one has replied
  • Where is the Qt Visual studio 2022 Extension?

    Unsolved
    5
    0 Votes
    5 Posts
    668 Views
    V
    @SGaist Thanks !
  • Calling a QT Button (C++) From the External Python Script

    Unsolved
    2
    0 Votes
    2 Posts
    152 Views
    SGaistS
    Hi and welcome to devnet, Qt is a C++ framework. From what you wrote your QtQuick GUI calls a C++ backend so the question is: do you really need the GUI to run when using your Python script ? You also have the option of implementing your code with PySide2/6 or PyQt5/6 if your main logic lies in Python.
  • How to use touchevent in QquickWidget on QMenu

    Unsolved
    4
    0 Votes
    4 Posts
    357 Views
    raven-worxR
    @Qt-Jo-Ha you might also need to set it on the QMenu itself
  • Read JSON from LocalHost and Dynamically fill QTableWidget.

    Solved
    9
    0 Votes
    9 Posts
    735 Views
    SGaistS
    Why a static variable ?
  • i need buffer for serial communication

    Unsolved
    3
    0 Votes
    3 Posts
    238 Views
    mrjjM
    Hi I don't know how to think as I've never used a buffer before In your Mainwindow / where serialport lives, add in the .h / class QByteArray data; // the buffer then in the read slot void MainWindow::readData() { data.append(m_serial->readAll( ) ); if (data.size() == 10 ) { // do processing data.clear(); } }
  • Image Gestures Example Windows / Laptops Trackpad

    Unsolved
    1
    0 Votes
    1 Posts
    152 Views
    No one has replied
  • How to convert QTCreator Linux project pro file to C/C++ library?

    Unsolved
    4
    0 Votes
    4 Posts
    327 Views
    artwawA
    @AnneRanch manual in that respect can be confusing as it tends to have all the options for MSVC and Windows. For gcc/clang not really needed. I quite often export parts of my code as a library if said code is/can be useful across the various tools I create, I do remember being confused about how to write it.
  • 0 Votes
    19 Posts
    4k Views
    D
    The QTBluetooth Central API is not supported on any platform. see the first table in Qt Bluetooth
  • Text of styled font is clipped

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    D
    @AhmedAlshawi said in Text of styled font is clipped: I have come across a similar issue but affecting the text on the bottom (see the p's and g's), and I can't seem to solve. Anyone have any idea? Don't change fontsize by stylesheet. Instead use QWidget::setFont() like this: tw = new QTabWidget(); tw->setFont(QFont(tw->font().family(), 16)); looks like: [image: 99d41259-2ceb-404b-94cf-1d54c187656e.jpg] You see - no vertical clipping :) I don't use stylesheets for font-changes at all. QTabBar was the first widget, I had to :( @raven-worx said in Text of styled font is clipped: he cleaner solution would be to intercept the size of the tab via a proxy style (but wont probably not work with a stylesheet style) or subclassing QTabBar and reimplement initStyleOption() (virtual since Qt6 only) Well, that may be true. When I digged into the sources, I thought I'd start to extend QSize QTabBar::tabSizeHint(int index) const ... ... but I decided not to spend too much time into patching Qt. Especially as the workaround costs nothing and works like charming :)