Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Can I create a so file for CMAKE Project, using QT?

    Solved
    9
    0 Votes
    9 Posts
    643 Views
    C
    @manykim said in Can I create a so file for CMAKE Project, using QT?: I do not reckon where i did wrong... Did the linker even find your my_hello library? Post the link related commands and output executed by the Makefile that CMake generated for you. make VERBOSE=1
  • How to solve the problem of inherits multi super classes

    Unsolved
    8
    0 Votes
    8 Posts
    728 Views
    Kent-DorfmanK
    How to solve the problem of inherits multi super classes In computer science texts this is called the "diamond problem". There are countless online discussions about it. It's not specifically a Qt problem, but a design paradigm challenge.
  • A nasty problem with moc

    Unsolved
    11
    0 Votes
    11 Posts
    673 Views
    jeremy_kJ
    An intermediate class can also work, so moc isn't asked to deal with not having the QObject base first. class Intermediate : public QObject { Q_OBJECT signals: void mySignal(); }; class OtherClass {}; class derived : public OtherClass, public Intermediate { };
  • How to automatically adjust the size of QListView?

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    A
    Thank you, the issue was solved by changing the stretch factors. It was enough to change listLayout->addWidget(button); to listLayout->addWidget(button,1,Qt::AlignTop); So the stretch factor ratio 1:0 allows to allign the button on the top of it's area.
  • How to get clicked item index of QScrollArea?

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    SGaistS
    You do realize that you are trying to reimplement the model/view paradigm rather than implementing a delegate that should paint three strings ?
  • How can I add custom widget to QListView?

    Solved
    17
    0 Votes
    17 Posts
    3k Views
    SGaistS
    A delegate does not handle tooltips, you should return them through the model for the Qt::ToolTipRole role.
  • How avoid memory leak with GUI programming

    Unsolved c++ gui developer destructor best practice
    12
    1 Votes
    12 Posts
    4k Views
    T
    @Christian-Ehrlicher said in How avoid memory leak with GUI programming: @TheEnigmist said in How avoid memory leak with GUI programming: VS points to p = p.scaled line that add every time 10k byte of data (50x50x4 bytes), and each time I create and detroy the widget where that QAbstractTableModel is I see in memory that all that Pixmap are never destroyed. There is no leak and can't be one - you should take a look into QPixmapCache and for the sake of performance and implicit sharing don't load the pixmap in your data() method every time. Yeah I just found out that I was really wrong with that :( I will fix it right now! So I can go over when see pixmap in my allocated memory due to QPixmapCache. Ofc is always better to improve my code and don't load so many times a pixmap! @Chris-Kawa said in How avoid memory leak with GUI programming: @TheEnigmist said in How avoid memory leak with GUI programming: So if I'm not wrong what is cached is not the file on disk, but its scaled version No. How would Qt know that it's the same pixmap? What's cached is the pixmap that you create from a file, and the path (with some additional info) becomes a key to look it up in the cache. I see, but why the debugger points me to the scaled() function when looking for the allocated memory istance?
  • menu option not displayed

    Unsolved
    10
    0 Votes
    10 Posts
    615 Views
    JoeCFDJ
    @Robert-M this works on Linux. Rich text format has to be selected for html in qlabel. <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>935</width> <height>296</height> </rect> </property> <property name="windowTitle"> <string>DirtyPHP Obfuscator</string> </property> <property name="windowIcon"> <iconset> <normaloff>dirtyphp.ico</normaloff>dirtyphp.ico</iconset> </property> <widget class="QWidget" name="centralwidget"> <widget class="QPushButton" name="pushButton_command"> <property name="geometry"> <rect> <x>90</x> <y>10</y> <width>291</width> <height>31</height> </rect> </property> <property name="text"> <string>Construct command Ctrl+1</string> </property> <property name="shortcut"> <string>Ctrl+1</string> </property> </widget> <widget class="QLabel" name="label_1"> <property name="geometry"> <rect> <x>20</x> <y>10</y> <width>61</width> <height>19</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-weight:600;">Step 1:</span></p></body></html></string> </property> <property name="textFormat"> <enum>Qt::RichText</enum> </property> </widget> <widget class="QTextBrowser" name="command_text"> <property name="geometry"> <rect> <x>19</x> <y>80</y> <width>901</width> <height>101</height> </rect> </property> <property name="verticalScrollBarPolicy"> <enum>Qt::ScrollBarAsNeeded</enum> </property> <property name="horizontalScrollBarPolicy"> <enum>Qt::ScrollBarAlwaysOff</enum> </property> </widget> <widget class="QLabel" name="label_command"> <property name="geometry"> <rect> <x>20</x> <y>50</y> <width>1181</width> <height>21</height> </rect> </property> <property name="font"> <font> <weight>75</weight> <bold>true</bold> </font> </property> <property name="text"> <string>Command:</string> </property> </widget> <widget class="QPushButton" name="pushButton_obfuscate"> <property name="geometry"> <rect> <x>90</x> <y>200</y> <width>291</width> <height>31</height> </rect> </property> <property name="text"> <string>Obfuscate application Ctrl+2</string> </property> <property name="shortcut"> <string>Ctrl+2</string> </property> </widget> <widget class="QLabel" name="label_2"> <property name="geometry"> <rect> <x>20</x> <y>200</y> <width>61</width> <height>19</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-weight:600;">Step 2:</span></p></body></html></string> </property> <property name="textFormat"> <enum>Qt::RichText</enum> </property> </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>935</width> <height>22</height> </rect> </property> <widget class="QMenu" name="menu_File"> <property name="title"> <string>&File</string> </property> <addaction name="actionChoose_application"/> <addaction name="actionChoose_recent_application"/> <addaction name="separator"/> <addaction name="actionChoose_composer_s_vendor_folder"/> <addaction name="actionChoose_framework"/> <addaction name="actionChoose_3rd_party_libraries_folders"/> <addaction name="separator"/> <addaction name="actionEdit_configuration_file"/> <addaction name="separator"/> <addaction name="actionExit"/> </widget> <widget class="QMenu" name="menu_Obfuscation"> <property name="title"> <string>&Obfuscation</string> </property> <addaction name="actionChoose_subdirectories_to_obfuscate"/> <addaction name="actionChoose_MVC_folders"/> <addaction name="actionChoose_result_folder"/> <addaction name="actionSet_other_options"/> <addaction name="separator"/> <addaction name="actionObfuscate_application"/> <addaction name="actionView_last_obfuscation_result"/> <addaction name="separator"/> <addaction name="actionClear_cache"/> </widget> <widget class="QMenu" name="menu_Help"> <property name="title"> <string>&Help</string> </property> <addaction name="actionBeginner_mode"/> <addaction name="actionAdvanced_mode"/> <addaction name="separator"/> <addaction name="actionDocumentation"/> <addaction name="actionWeb_page"/> <addaction name="actionReport_bug"/> <addaction name="actionSuggest_improvement"/> <addaction name="separator"/> <addaction name="action_About_program"/> </widget> <addaction name="menu_File"/> <addaction name="menu_Obfuscation"/> <addaction name="menu_Help"/> </widget> <widget class="QStatusBar" name="statusbar"/> <action name="actionChoose_application"> <property name="text"> <string>Choose &application...</string> </property> </action> <action name="actionChoose_composer_s_vendor_folder"> <property name="text"> <string>Choose Composer's &vendor folder...</string> </property> </action> <action name="actionChoose_framework"> <property name="text"> <string>Choose &framework...</string> </property> </action> <action name="actionChoose_3rd_party_libraries_folders"> <property name="text"> <string>Choose 3rd party &libraries folders...</string> </property> </action> <action name="actionEdit_configuration_file"> <property name="text"> <string>Edit frameworks &configuration file</string> </property> </action> <action name="actionChoose_subdirectories_to_obfuscate"> <property name="text"> <string>Choose &subdirectories to obfuscate...</string> </property> </action> <action name="actionChoose_result_folder"> <property name="text"> <string>Choose &result folder...</string> </property> </action> <action name="actionSet_other_options"> <property name="text"> <string>Set other op&tions...</string> </property> </action> <action name="actionObfuscate_application"> <property name="text"> <string>&Obfuscate application...</string> </property> </action> <action name="actionExit"> <property name="text"> <string>E&xit</string> </property> </action> <action name="actionDocumentation"> <property name="text"> <string>&Documentation</string> </property> </action> <action name="actionReport_bug"> <property name="text"> <string>&Report bug</string> </property> </action> <action name="action_About_program"> <property name="text"> <string>Abou&t DirtyPHP Obfuscator...</string> </property> </action> <action name="actionChoose_MVC_folders"> <property name="text"> <string>Choose &MVC folders...</string> </property> </action> <action name="actionWeb_page"> <property name="text"> <string>&WWW page</string> </property> </action> <action name="actionBeginner_mode"> <property name="checkable"> <bool>true</bool> </property> <property name="checked"> <bool>true</bool> </property> <property name="text"> <string>&Beginner's mode</string> </property> </action> <action name="actionAdvanced_mode"> <property name="checkable"> <bool>true</bool> </property> <property name="text"> <string>&Advanced mode</string> </property> </action> <action name="actionChoose_recent_application"> <property name="text"> <string>Choose &recent application...</string> </property> </action> <action name="actionView_last_obfuscation_result"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> <string>&View last obfuscation result...</string> </property> </action> <action name="actionClear_cache"> <property name="text"> <string>&Clear cache</string> </property> </action> <action name="actionSuggest_improvement"> <property name="text"> <string>Suggest improvement</string> </property> </action> </widget> <resources/> <connections/> </ui>
  • Convert QByteArray to vector<uint8_t>

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    JoeCFDJ
    @JonB nice solution. Is std::vector<uint8_t> c( bytes.begin(), bytes.end() ) more C++ style-ish?;
  • Tag - Length - Value parse in qt

    Solved
    6
    0 Votes
    6 Posts
    467 Views
    S
    JonB is completely right. You initialize the QByteArray with "numerical garbage" and so the de-serialization fails. Details: If you initialize QByteArray with a const char * you will get the ASCII codes as values. A "0" will thus yield a value of 48, which is definitely not a valid enum TLV_TYPE. And even if it would be a numerical zero, it would decode to TLV_TYPE::UNDEFINED, which doesn't sound reasonable. Please use data which was generated from a serialization.
  • "Sticky option" for widget based window

    Unsolved
    1
    0 Votes
    1 Posts
    193 Views
    No one has replied
  • QSlider connect and C++ lambda ?

    Unsolved
    5
    0 Votes
    5 Posts
    824 Views
    S
    @Chris-Kawa said in QSlider connect and C++ lambda ?: Just a note here. Since you're not using this in the lambda you don't need to capture it. Just an additional note. If you are actually using this inside the lambda, use this as context object (third parameter, right before the lambda) inside the connect(). If it's another object, use that object instead. Once the context object is deleted it will automatically disconnect the lambda. You'll get some strange behavior if you are calling a slot on a deleted object. In your specific example a context object is not needed.
  • This topic is deleted!

    Unsolved
    26
    0 Votes
    26 Posts
    97 Views
  • MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10

    25
    0 Votes
    25 Posts
    4k Views
    P
    @paokaras98 said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10: Ok I got your point. However, suppose I have a customer to sell my software and this customer does not want to mess up with installations. He wants only an all-in-one installer to install the app and the dependencies(in my case the dbms server). So the dbms server .msi should be somehow included to my final installer and executed... am I right?. Thank your for your clarification. I will make my research now
  • How to change shortcuts?

    Unsolved
    2
    0 Votes
    2 Posts
    194 Views
    jsulmJ
    @icebergenergy What exactly is your question? Just select what you want to change and enter the key sequence in "Key sequence". It is even explained in the link you posted. If something is not clear then please ask a clear question.
  • Sniffing broadcast udp socket on specific MAC address

    Unsolved network udp
    3
    0 Votes
    3 Posts
    675 Views
    C
    If something else sends a UDP datagram to the sub-net IP broadcast address (e.g. 192.168.1.255 on IP subnet 192.168.1.0/24) then any device connected to, and configured for, that IP sub-net should receive the datagram. You need to know the port that the UDP datagram was sent to also. Assuming your listeneing device is connected to the relevant physical network and has suitable IP address/subnet mask, then all you should need is to QUdpSocket::bind() to your IP and port.
  • QSvgWidget load svg Datei, "libpng warning: iCCP: known incorrect sRGB profile"

    Unsolved
    2
    0 Votes
    2 Posts
    604 Views
    Christian EhrlicherC
    @rs_elk said in QSvgWidget load svg Datei, "libpng warning: iCCP: known incorrect sRGB profile": However, shouldn't this warning occur when loading a PNG file instead? Yes, you're loading a png somewhere.
  • fatal error: double-conversion/double-conversion.h: No such file or directory

    Unsolved
    4
    0 Votes
    4 Posts
    940 Views
    Christian EhrlicherC
    Then your source package was not completely unpacked because this header is provided by Qt: https://code.qt.io/cgit/qt/qtbase.git/tree/src/3rdparty/double-conversion/double-conversion
  • QT6 QComboBox open in drawComplexControl

    Unsolved
    7
    0 Votes
    7 Posts
    695 Views
    TrilecStudiosT
    @TrilecStudios for the sake of completeness: This is the current implementation for those interested. //a simple implementation the calls the styling function void CharcoalStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { case CC_ComboBox: { setComboboxStyle(option, painter, widget ) ; break; } default: QProxyStyle::drawComplexControl(control, option, painter, widget); break; } } //the basic implementation of drawing a style for combobox void CharcoalStyle::setComboboxStyle(const QStyleOption *option, QPainter* painter, const QWidget *widget) const { const auto comboOption = qstyleoption_cast<const QStyleOptionComboBox *>(option); const auto comboBox = qobject_cast<QComboBox*>(const_cast<QWidget*>(widget)); if(!comboOption ) return; bool isDown = (option->state & QStyle::State_Sunken); bool isEnabled = (option->state & QStyle::State_Enabled); bool hasFocus = (option->state & QStyle::State_HasFocus && option->state & QStyle::State_KeyboardFocusChange); bool isOver = (option->state & QStyle::State_MouseOver); bool isOn = (option->state & QStyle::State_On); enum DESIGN { NormalDesign = 0, FlatDesign = 1, Design1 = 2, Design2 = 3 }; int design = NormalDesign; QColor bgColor = ComboboxBg; QColor fgColor = ComboboxFg; QColor borderColor = ComboBoxBorder; QColor iconColor = ComboBoxIcon; QRect rect = comboOption->rect; // prepare and load existing defaults QFont font = comboBox->font(); Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter; // override any additional settings to take care of a design property being set (defined in header) if (comboBox->property(Design1Property.toStdString().c_str()).toBool()) { design = Design1; bgColor = design1Bg; fgColor = design1Fg; borderColor = design1Border; iconColor = design1Icon; } // design = NormalDesign; //defined at top of function as default // ajust the colours if it's on to being slightly brighter for on state if( isDown ) { bgColor = bgColor.lighter(140); fgColor = fgColor.lighter(110); borderColor = borderColor.lighter(110); iconColor = iconColor.lighter(110); } // ajust the colours on a disabled state adjusting saturation, lightness and transparency if( !isEnabled ) { // Convert the base color to HSL and adjust the saturation and brightness bgColor = QColor::fromHslF(bgColor.hslHueF(), bgColor.hslSaturationF() * 0.7, bgColor.lightnessF() * 0.8); fgColor = QColor::fromHslF(fgColor.hslHueF(), fgColor.hslSaturationF() * 0.7, fgColor.lightnessF() * 0.8); iconColor = QColor::fromHslF(iconColor.hslHueF(), iconColor.hslSaturationF() * 0.7, iconColor.lightnessF() * 0.8); bgColor.setAlpha(128); //a little bit of transparency borderColor = bgColor; } // ajust the colours if we are hovering over the button or widget if( isOver ) { bgColor = bgColor.lighter(112); fgColor = fgColor.lighter(112); borderColor = borderColor.lighter(112); iconColor = iconColor.lighter(112); } //setup the painter painter->save(); //painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->setBrush(bgColor); painter->setFont(font); //path handles anti-aliasing a lot better specially for rounded QPainterPath path; // draw the appropriate style switch (design) { case Design1: path.addRect( rect ); painter->setPen(QPen( borderColor,2 )); if( isOn ) { painter->drawPath(path); drawArrow( painter, Qt::DownArrow, rect, comboOption,iconColor); } else { painter->fillPath(path, bgColor); drawArrow( painter, Qt::RightArrow, rect, comboOption,iconColor); } painter->setPen(QPen(fgColor, 1)); painter->drawText(rect.adjusted(4, 0, -18, 0), alignment, comboOption->currentText); break; default: painter->setPen(QPen( borderColor,1 )); qreal radius = option->rect.height() / 2; path.addRoundedRect(rect, radius,radius); if( isOn ) { painter->drawPath(path); painter->setBrush(bgColor); drawArrow( painter, Qt::DownArrow, rect, comboOption,iconColor); } else { painter->fillPath(path, bgColor); drawArrow( painter, Qt::RightArrow, rect, comboOption,iconColor); } painter->setPen(QPen(fgColor, 1)); painter->drawText(rect.adjusted( radius , 0, -18, 0), alignment, comboOption->currentText); break; } painter->restore(); }
  • Error trying to add Adding Qt Quick Designer Components to Qt Installation

    Solved
    14
    0 Votes
    14 Posts
    2k Views
    M
    I found a solution to the problem. I ended up installing msys2 and through that installing mingw-w64 GCC using these commands: pacman -S mingw-w64-ucrt-x86_64-gcc pacman -S --needed base-devel mingw-w64-x86_64-toolchain This allowed me to build and install the Qt Quick Designer Components without any errors. I was still having an error with Qt Creator recognising the modules, but reinstalling resolved that, so it's all working fine now. Thanks.