Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • QWidget across the desktop space in macos?

    Unsolved
    3
    0 Votes
    3 Posts
    356 Views
    Z
    @stryga42 Thank you for your reply, what I want to do is on the Mac system, when I switch the desktop space, let the window switch with it and display it on the top layer forever. What I did try is as follows: // in .mm file, My own widget is subclass of QWidget NSPanel *window = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, size.width(), size.height()) styleMask:NSWindowStyleMaskFullSizeContentView | NSWindowStyleMaskBorderless | NSWindowStyleMaskNonactivatingPanel backing:NSBackingStoreBuffered defer:YES]; [window setHasShadow:false]; [window setHidesOnDeactivate:false]; [window setBackgroundColor:NSColor.clearColor]; [window setTitlebarAppearsTransparent:true]; [window setTitleVisibility:NSWindowTitleHidden]; [window setFloatingPanel:true]; [window setLevel:NSScreenSaverWindowLevel - zPosition]; [window setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary]; NSView *nativeWidgetView = (NSView*)(this->winId()); window.contentView = nativeWidgetView; This approach achieved my purpose, but it also caused a series of event distribution problems, such as not receiving QEvent::Enter...I don't know what to do and if there is any other way to do it?
  • Qt creator 9.0.2 inline editor error messages while compilation is fine

    Unsolved
    1
    0 Votes
    1 Posts
    161 Views
    No one has replied
  • QDialog close action on pressing Window 'X'

    Unsolved
    5
    0 Votes
    5 Posts
    369 Views
    D
    @JonB Got it, let me try that. Thank you!
  • QValidator: no spaces

    Solved
    8
    0 Votes
    8 Posts
    835 Views
    JonBJ
    @Dummie1138 Good on the backslashes, but no you are going too far. The attempt you had is actually close. It would need to be "^\\S*$" But if that doesn't work the link I referenced says QRegExpValidator already assumes ^...$ around your expression, i.e. complete match. So your ^/$ may be being taken literally. Try just "\\S*" ?
  • Scroll a pdf document in QPdfView

    Unsolved
    3
    0 Votes
    3 Posts
    368 Views
    F
    @jsulm said in Scroll a pdf document in QPdfView: @Faust-Faust Since it inherits https://doc.qt.io/qt-6/qabstractscrollarea.html it is possible I knew, but he didn't give me the method. QScrollBar *scrol = view->verticalScrollBar(); scrol->setSliderPosition(scrol->sliderPosition() + 100); Thank you.
  • Using Qt Virtual Keyboard to use predictive text input

    Unsolved
    1
    0 Votes
    1 Posts
    132 Views
    No one has replied
  • Drag n drop problem with Linux

    Unsolved
    3
    1 Votes
    3 Posts
    384 Views
    M
    @stryga42 Ubuntu 22.04.2 LTS with the standard wayland WM. I am dragging within my app (I drag a treeItem from its location to another in the same treeview). The code itself is very basic and it works as expected on windows void ProjectWidget::dragMoveEvent(QDragMoveEvent * event) { QTreeWidgetItem* currentItem = itemAt(event->position().toPoint()); if (currentItem == NULL) { event->ignore(); return; } if (latestDraggedItem == NULL) { event->ignore(); return; } QVariant v = latestDraggedItem->data(0,Qt::UserRole); if (v.value<ModelTemplate *>()) { if (currentItem == cardNode) { event->setDropAction(Qt::MoveAction); event->accept(); return; } } event->ignore(); }
  • Connecting Local MSSQL DB With QtSQL

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    piervalliP
    @UmeyrMSekban Usually I use only a standard connection string, try with this //Driver={SQL Server Native Client 11.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; m_database = QSqlDatabase::addDatabase("QODBC", connectionName); QString dns = QString("Driver={SQL Server Native Client 11.0};Server=%1;Database=%4;Uid=%2;Pwd=%3;") .arg(m_host,m_userName,m_password, m_nameDB); qDebug() << "ODBC connection string" << dns << "driver"; m_database.setDatabaseName(dns); stato = m_database.open(); if(!stato){ qCritical() << m_database.lastError().text() << QSqlDatabase::drivers(); }
  • Project ERROR: Unknown module(s) in QT: webengine

    Solved
    9
    0 Votes
    9 Posts
    5k Views
    jsulmJ
    @jorTry85 As @SGaist wrote: you need to use Microsoft compiler, not MinGW.
  • qChecksum()

    Solved
    4
    0 Votes
    4 Posts
    938 Views
    W
    @Chris-Kawa Thanks for the pointer to the code. I'm new to Qt and still finding my way around.
  • Can I create a so file for CMAKE Project, using QT?

    Solved
    9
    0 Votes
    9 Posts
    640 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
    724 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
    667 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
    612 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
    463 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.