Skip to content
QtWS25 Last Chance
  • 0 Votes
    3 Posts
    162 Views
    That makes sense, thank you.
  • 0 Votes
    4 Posts
    334 Views
    @Khamza First to answer your question. Your new code delays the update till after the text edit has been shown. In that sense it is similar to the QTimer approach. For unknown reason you are claiming the code does not work correctly until after the text edit has been shown. There are cases in Qt which this is necessary. In particular sizes of widgets are not calculated till they are actually shown, so code which requires to know a size is often delayed in one of the above two fashions. HOWEVER I was never convinced by your assertion "The function itself is called but neither text is inserted nor block format changed:". While I could believe that possibly an operation on textCursor() might require the text edit to be shown I never thought that insertPlainText() for sure would depend on that. It should be callable any time, including e.g. during construction. I have now had time to create a minimal repro. Here are the 3 files: #include "passwordshowarea.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); PasswordShowArea w; w.show(); return a.exec(); } #ifndef PASSWORDSHOWAREA_H #define PASSWORDSHOWAREA_H #include <QTextEdit> class PasswordShowArea : public QTextEdit { Q_OBJECT public: PasswordShowArea(QWidget *parent = nullptr); private: void init(); void updateBlockFormat(); }; #endif // PASSWORDSHOWAREA_H #include <QAbstractTextDocumentLayout> #include <QTimer> #include "passwordshowarea.h" PasswordShowArea::PasswordShowArea(QWidget *parent) : QTextEdit(parent) { init(); //doesn't work updateBlockFormat(); // works - gpt4 suggest // QTimer::singleShot(0, this, &PasswordShowArea::updateBlockFormat); } void PasswordShowArea::init() { // QObject::connect(document()->documentLayout(), &QAbstractTextDocumentLayout::update, // this, &PasswordShowArea::updatePasswordShowArea); setTextColor(palette().color(QPalette::Text)); } void PasswordShowArea::updateBlockFormat() { insertPlainText("Some text"); QTextBlockFormat fmt = textCursor().blockFormat(); fmt.setTextIndent(20); fmt.setLineHeight(fontMetrics().height() * 2, QTextBlockFormat::LineDistanceHeight); fmt.setBackground(Qt::red); textCursor().mergeBlockFormat(fmt); } I have made couple of tiny tweaks where I did not have all of your code. I added fmt.setBackground(Qt::red); so that we had something to see. And here is what I get: [image: f7a0cc88-52cf-437f-8f38-cd3c2983b5bf.png] You can see that not only do I get the inserted text but I do also get the QTextBlockFormat changes. Identical if I change it to only call updateBlockFormat() on the delayed timer. Ubuntu 24.04, Qt 6.4.2. Sooo.... I suggest you try just this code.
  • 0 Votes
    2 Posts
    240 Views
    @Joe-von-Habsburg said in Add ready widget into widget: I am leaving an example QtCreator Preferences is your example?! So you want something similar?! You could dig into QtCreator source code and check out how it's done. For this I would use QToolButton to populate the "menu bar" on the left and a QStackedWidget to display the content pages on the right. Actually the QStackedWidget is more like centered, as the whole window you see is divided into two sections (~15% / ~85%) for the menu and the "rest" (the QStackedWidget for the content). Is it Qt designer form class (.cpp && .h && .ui)? The "right side" is the content widget... In case of QtCreator a custom QWidget containing a QTabWidget for the Text Editor settings among many other things. The parent of all this is probably a QStackedWidget as I presumed above. What approach (with or without Designer Form) you pick to implement this has nothing to do with how it works. Both ways are possible.
  • 0 Votes
    6 Posts
    638 Views
    @Christian-Ehrlicher said in Widget from scratch using pImpl, how to Q_PRIVATE_SLOT?: As I said the pmf syntax needs a QObject as sender and receiver. Ah sorry, while I was editing my example code I missed your reply :) Oh wow didn't know that :0 So the ( SIGNAL(), SLOT() ) connection stuff is not 100% identical in terms of use-case and compatibility with the Functor-based connections? Good to know. @Christian-Ehrlicher said in Widget from scratch using pImpl, how to Q_PRIVATE_SLOT?: Maybe you can also take a look on QObjectPrivate::connect() in qobject_p.h (when someone asks - I don't know this function... 🙂) Yeah, I checked the Qt Private sources here and there while I was building my widget to see how it's done. Haven't seen this exact part, but will visit it again ;-) Since I don't want to include the Qt Private source completely (which would make my widget highly dependent on a single Qt version), I made my own WidgetPrivate based on QWidgetPrivate "style" but without inheriting it... so no QObjectData, QObjectPrivate and whatnot... for me ;-) Edit: @Christian-Ehrlicher said in Widget from scratch using pImpl, how to Q_PRIVATE_SLOT?: Maybe you can also take a look on QObjectPrivate::connect() in qobject_p.h (when someone asks - I don't know this function... 🙂) This function? What is there to see? Other than QObjectPrivate::connect. You mean the use of two QObject Functors? when someone asks - I don't know this function Nobody will know 🤐 One way is to derive the private class from QObject or use a lambda. If one way to make it work is using the SIGNAL / SLOT keywords again, I will probably try it. Tried lambda, did not work either :/ Or maybe I was doing something wrong. Edit_II: I made my actual code work, using String-based connections while I moved the connect statement to the WidgetPrivate::init() function and hid the QTimer also behind the WidgetPrivate data. Not 100% pleased, tho :D Is it a good idea to make the Impl class a QObject?! What's your recommendation? @SGaist oh lol even missed your comment too :D Was about to add the code anyway :)
  • 0 Votes
    3 Posts
    488 Views
    @StudentScripter You can put pointers to widgets into arrays/lists/maps as you please and use those for iterating through them etc. You can't get Designer to do that for you, so you have to manually populate the arrays/lists from the ui->... instance variables yourself (after setupUi()). You can also visit all widgets of a given type, without setting anything up, via topWidget->findChildren<QLineEdit *>(). You can "group" widgets at design-time by e.g. creating a "holding" container QWidget or QFrame or QGroupBox if that helps. For buttons there is also QButtonGroup.
  • 0 Votes
    2 Posts
    231 Views
    @jdent said in How do I share a custom chart widget i developed for Qt Designer?: I understand part of being in the open source license is that we contribute You don't have to. It's always nice, but nobody forces you to share your projects that you have created with your community license. Well, I have developed a QtDesigner plugin widget for charts I would like to share. How do I proceed? Read about how to deploy an app: https://doc.qt.io/qt-6/windows-deployment.html https://doc.qt.io/qt-6/deployment.html https://wiki.qt.io/Deploy_an_Application_on_Windows
  • 0 Votes
    3 Posts
    342 Views
    @Pl45m4 Thanks!!!!
  • 0 Votes
    22 Posts
    3k Views
    @starkm42 Thanks for the reply, the issue was to do with the fact mosquitto was compiled with a different library. To avoid this I am just going to run a ubuntu VM Thanks everyone for the help.
  • 0 Votes
    2 Posts
    373 Views
    Hi, You could check KDE's Kontact application. If I remember correctly they have a journal part that might be of interest.
  • 0 Votes
    2 Posts
    312 Views
    @Nivedkarun Use QWebEngineView
  • 0 Votes
    1 Posts
    210 Views
    No one has replied
  • 0 Votes
    5 Posts
    527 Views
    @jsulm I got it now. Thank you!!
  • 0 Votes
    6 Posts
    1k Views
    @ZaidX said in Visualize Realtime pointclouds on QT widget: I dont understand what do you mean by "if its pure qt without any hardware accleration" . With this I mean that you derive from QWidget and implement paint() using QPainter. This is comparatively slower than OpenGL or Vulkan. For these you need a QOpenGLWidget or QVulkanWindow. This then allows to use OpenGL or Vulkan directly for drawing while still using Qt for everything else (including mouse handling). @ZaidX said in Visualize Realtime pointclouds on QT widget: Bandwith: 3.55MB/s Frequency: 4.9Hz This sounds doable. Though it doesn't mean it is easy to reach interactive speeds.
  • 0 Votes
    4 Posts
    448 Views
    Hey @mrjj Digging out this topic... as I figure better to stick it in the same tree... Anyway, any idea how to make QScrollArea behave correctly too? Making it container does not let me drag widgets on it :/
  • 0 Votes
    4 Posts
    590 Views
    @Saviz Sorry, I don't know such article. But basically create a settings object and store the settings in it instead of in widgets classes.
  • 0 Votes
    11 Posts
    4k Views
    @Dean21 @JoeCFD asked where the mqtt libs you built are stored, not where the code is...
  • 0 Votes
    4 Posts
    611 Views
    @Christian-Ehrlicher in the same strange way, i have an void : void QtVsPlayer::FullScr() { if (QtVsPlayer::isFullScreen()) { QtVsPlayer::showNormal(); this->ui->menubar->setVisible(true); if (!Zoomed) this->ui->statusbar->setVisible(true); } else { QtVsPlayer::showFullScreen(); this->ui->menubar->setVisible(false); this->ui->statusbar->setVisible(false); } return; } this void work, i have fullscreen video. now in mousemove event i have if (!this->ui->actionMasquer_les_controles->isChecked() and WVideoCtrls->isHidden() and this->ui->actionAuto_hide_controls->isChecked()) { if(!Zoomed and QtVsPlayer::isFullScreen() == false) ui->statusbar->setVisible(true); WVideoCtrls->show(); WVideoCtrls->activateWindow(); WVideoCtrls->raise(); this->centralWidget()->lower(); this->centralWidget()->stackUnder(WVideoCtrls); } if (QtVsPlayer::cursor() == Qt::BlankCursor) { QtVsPlayer::unsetCursor(); } return; the goal is to display videocontrols, like play, pause and so on, but not the status bar in full screen, but it is shown, zoomed is false but isfullscreen is no such value
  • 0 Votes
    4 Posts
    692 Views
    I would check the internals of the other platform plugins to see how they are used by these classes.
  • 0 Votes
    1 Posts
    384 Views
    No one has replied