Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • How to use the Private class/dpointer approach?

    Solved
    4
    0 Votes
    4 Posts
    396 Views
    S
    @SGaist The slot is declared and defined in the actual code, but the same error. Is it necessary to include the moc-generated file inside the cpp file in this case? We usually compile them as separate files and link everything together at the end.
  • QTouchEvent error

    Unsolved
    3
    0 Votes
    3 Posts
    423 Views
    J
    @JoeCFD In order to troubleshoot this problem, we write a very simple project(testDemo), which only contains a QMainWindow. when we touch the mainwindow, and trigger a new dialog from other exe at the same time, the touchevent of this simple project also don't work normally. bool MainWindow::event(QEvent *event) { switch (event->type()) { case QEvent::MouseButtonPress: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[mousePress]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous(); QMainWindow::mousePressEvent(mouse); break; } case QEvent::MouseButtonRelease: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[MouseRelease]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous(); QMainWindow::mouseReleaseEvent(mouse); break; } case QEvent::MouseMove: { QMouseEvent* mouse = (QMouseEvent*)event; gPos = mouse->localPos(); qDebug() << "[MouseMove]" << (Qt::MouseEventSource)mouse->source() << (Qt::MouseButton)mouse->button() << gPos.rx() << gPos.ry() << event->spontaneous() << cnt2++; QMainWindow::mouseMoveEvent(mouse); break; } case QEvent::TouchBegin: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchBegin] : " << (Qt::TouchPointStates)touchEvent->touchPointStates() // << (QTouchDevice::DeviceType)touchEvent->device()->type() 0 << cnt++ << touchEvent->touchPoints().count() << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // event->ignore(); // return true; } case QEvent::TouchUpdate: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchUpdate] : " // << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++ << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // return true; } case QEvent::TouchEnd: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchEnd] : " // << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++ << (Qt::TouchPointState)touchEvent->touchPoints().at(0).state() << event->spontaneous(); break; // return true; } case QEvent::TouchCancel: { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); qDebug() << "[TouchCancel] : " << (QTouchDevice::DeviceType)touchEvent->device()->type() << cnt++; break; // return true; } case QEvent::FocusIn: { QFocusEvent *fcEvent = static_cast<QFocusEvent *>(event); qDebug() <<"[focus in] : "<< (Qt::FocusReason)fcEvent->reason() ; // QTouchEvent* event = new QTouchEvent(QEvent::ActivationChange); // qApp->postEvent(qApp,event); break; } case QEvent::FocusOut: { QFocusEvent *fcEvent = static_cast<QFocusEvent *>(event); qDebug() <<"[focus out] : " << (Qt::FocusReason)fcEvent->reason() ; break; } default: // if(event->spontaneous()) { // event->accept(); // return true; // } if(event->type() != QEvent::HoverMove && event->type() != QEvent::Move) { qDebug() << (QEvent::Type)event->type() << event->spontaneous(); } break; } return QMainWindow::event(event); } We have tried to print the event loop during this operation, we found that the first time we touch the testDemo, touchbegin, mousemove can be printed, and mouserelease event can be printed when we release our finger from the testDemo; When we first touch the testDemo with one finger(finger1), and we trigger a new dialog from other exe(for example, click any tool bar of qtcreator ) with another finger(finger2). This time we release finger2 first, touch the testDemo again, it can only print the mousemove with the same position of the last mousemove pos, and the touch event can not be worked normally until we unplug the docking station of Surface. I have found the same question in this link https://forum.qt.io/topic/135219/qt-widgets-not-responding-to-touch-event-sometimes. There is still no issue how to solve this problem. Do you have any suggestion on this question? And thanks for your help~
  • Does drawLine(...) draw endpoints?

    Moved Unsolved
    4
    0 Votes
    4 Posts
    340 Views
    SGaistS
    That's a good question, I currently don't remember whether there will be optimisation in the backend if several operations happens on the same segment. Based on the names you use, wouldn't it make more sense to use OpenGL ?
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    52 Views
  • Qt plugin for Visual Studio 2022 not working well

    Unsolved
    1
    0 Votes
    1 Posts
    170 Views
    No one has replied
  • Two questions about QDialog

    Unsolved
    4
    0 Votes
    4 Posts
    267 Views
    SGaistS
    @Perdrix do you mean your question about onActivateWindow ? The thing is that I don't know what that function does and when it is called. As for folders, are folders allowed ? Should only a subset of files be processed ? That's again something you should manage on drop.
  • Two-widgets stacked widget switching when mouse hovers it.

    Solved stackedwidget hover
    6
    0 Votes
    6 Posts
    828 Views
    JonBJ
    @dauriac Ah yes :) When you change the widget being hovered over you get a new hover event for the new widget.....
  • window disappears when minimized, on windows 10

    Solved
    4
    0 Votes
    4 Posts
    4k Views
    JonBJ
    @febinaf I meant to mention one other thing. For hiding one window and showing another, depending on your usage either QStackedLayout or QWizard would be preferable/easier, if suits.
  • Unknown module(s) in QT: imageformats

    Solved
    9
    0 Votes
    9 Posts
    666 Views
    C
    @MyNameIsQt You need to install Qt 6.4 along with image formats module. And why are you trying to use qt4 (which is Qt version 4)? It's not compatible with your compiler.
  • When I used RTC on different thread all GUI QT is lock?

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    stackprogramerS
    @J-Hilk @Jsum @all Thanks very much Finally I concluded that: Case one: my tread class that run to interrupt, Qthread was dynamic but interrupt need be static. For overcoming this problem I used a singleton design pattern. Case two: it is not related to GUI main thread, I had a /dev/rtc0 in Linux kernel, and I used it in my application now we examine it, we concluded that We need to slow down the rtc interrupt, I changed the interrupt time from 1 ms to 60ms now everything is ok and GUI main thread works correctly. RTC* RTC::instance = nullptr;
  • Qt creator application not fitting to the windows tablet screen

    Unsolved
    2
    0 Votes
    2 Posts
    196 Views
    ?
    @qt121 Hi could you please be a little more explicit about the problem ? What do you mean by "based on my desktop and tablet settings" ? What do you mean that it is "not fitting to the windows tablet screen" ? Do you mean you want fullscreen ? first : QtQuick or QtWidget ? assuming this is what you want QtWidget : do window->showMaximized() ; QtQuick with window instanciated on C++ side with QQuickWindow : exactly as in QtWidget case QtQuick with window instanciated on QML side (only QQmlEngine on C++ side) : Window { id: mainWindow // other stuff Component.onCompleted: showMaximized() } showFullScreen is also available in all cases
  • How to know if QTimeEdit field clicked?

    Unsolved
    5
    0 Votes
    5 Posts
    420 Views
    C
    @masa4 Don't forget to mark this topic as solved, it would help future readers to know that there's a solution.
  • Can't send file via SMTP protocol

    Solved
    15
    0 Votes
    15 Posts
    992 Views
    R
    @ChrisW67, Yes! You're right! Thank you very much. The error was only that the logic of the code was incorrect. I have corrected the structure of creating a message: QByteArray boundary = "my_boundary"; QByteArray message; message.append(QString("From: ").toUtf8() + QString(from).toUtf8() + QString("\r\n").toUtf8()); // message.append(QString("To: %1").arg(ui->lEdit_addrFrom->text()).toUtf8() + QString(to).toUtf8() + QString("\r\n").toUtf8()); message.append(QString("To: ").toUtf8() + QString(to).toUtf8() + QString("\r\n").toUtf8()); message.append("Subject: " + QString(subject).toUtf8() + "\r\n"); message.append("MIME-Version: 1.0\r\n"); message.append("Content-Type: multipart/mixed; boundary=" + boundary + "\r\n\r\n"); // Body message.append("--" + boundary + "\r\n"); message.append("Content-Type: text/plain\r\n\r\n"); message.append(QString(body).toUtf8() + "\r\n\r\n"); // Attachment message.append("--" + boundary + "\r\n"); message.append("Content-Disposition: attachment; filename=\"" + fileInfo.fileName().toUtf8() + "\"\r\n"); message.append("Content-Type: " + mime.name().toUtf8() + "; name=\"" + fileInfo.fileName().toUtf8() + "\"\r\n"); message.append("Content-Transfer-Encoding: base64\r\n\r\n"); message.append(fileData.toBase64() + "\r\n\r\n"); // Completing a message message.append("--" + boundary + "--\r\n"); //==================================================================================== socket.write(message); socket.write(".\r\n"); // socket.flush(); And also removed socket.flush(); when sending the MESSAGE command and when sending the QUIT command And now everything works as it should. Once again thank you very much. Now there is only one problem left to fix. Some SMTP servers do not understand Ukrainian and Russian encodings. Incomprehensible letters are shown instead of Cyrillic UPD: I also corrected the encoding. Where is the comment BODY Instead of a line message.append("Content-Type: text/plain\r\n\r\n"); Need to add message.append("Content-Type: text/plain; charset=UTF-8\r\n\r\n"); And above, where the addressee is formed, you need instead of this line message.append("Content-Type: multipart/mixed; boundary=" + boundary + "\r\n\r\n"); Write this line: message.append("Content-Type: multipart/mixed; charset=UTF-8; boundary=" + boundary + "\r\n\r\n"); Thank you all for your help :)
  • Templates missing in Qt6?

    Unsolved
    2
    0 Votes
    2 Posts
    155 Views
    A
    could this possible be related? [image: b7889735-c2f6-4e7f-bdd2-25235845836d.png]
  • This topic is deleted!

    Solved
    3
    0 Votes
    3 Posts
    27 Views
  • QDateTime convertion fromString is invalid (guess because of time zone)

    Unsolved
    2
    0 Votes
    2 Posts
    193 Views
    B
    @RoadCoder That's a Qt::ISODate format, you can use fromString(datetime, Qt::ISODate) QDateTime::fromString() is a static method, it won't do any change to your dt object. So the correct way is QDateTime dt = QDateTime::fromString(datetime, Qt::ISODate);
  • YCbCr in QColor?

    Unsolved
    2
    0 Votes
    2 Posts
    259 Views
    SGaistS
    @Tony-OttoCODE hi and welcome to devnet, That's a question you should rather ask on the developer mailing list. You'll finder there Qt developers/maintainers. This is a user forum. I am currently unsure about the interest of having a different color space used with QColor. Typically a jpeg image shown on a QLabel has been converted to RGB before being shown.
  • How to run Qt programs on Linux platform support hot plug?

    Unsolved
    2
    0 Votes
    2 Posts
    213 Views
    SGaistS
    Hi and welcome to devnet, I would rather go with a system solution rather than modify Qt. Take a look at persistent-evdev. It seems it might do the job (note: I have not used it myself). You should also give a bit more information about the context of your project.
  • Qt validator doesnt work like described in docs

    Unsolved
    8
    0 Votes
    8 Posts
    380 Views
    C
    @masa4 It has setMaximum and setMinimum, which seems to be exactly what you need
  • QMessageBox exec only returns 1024 or 4194304...

    Unsolved
    5
    0 Votes
    5 Posts
    798 Views
    SGaistS
    @Paddle ni worries ! Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)