Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qtwidgets
    Log in to post

    • SOLVED QTreeView doesn't change its behaviour for child items even if flags are correctly set
      General and Desktop • c++ qtreeview qtwidgets flags • • famastefano  

      2
      0
      Votes
      2
      Posts
      23
      Views

      A colleague of mine, that used Qt for years, helped me. The culprit was (other than me) that I wrongly created the parent of the children.
    • SOLVED Stylesheet css or xml widgets pyqt6 python
      Qt 6 • python stylesheet css xml qtwidgets • • Jbone73  

      5
      0
      Votes
      5
      Posts
      130
      Views

      @jsulm Thank you very much ! It's exactly what I needed. In the top !
    • UNSOLVED How to support an autohiding taskbar on Windows?
      General and Desktop • windows qtwidgets taskbar • • Krakenus00  

      2
      0
      Votes
      2
      Posts
      115
      Views

      @Krakenus00 Hello can you add the picture that you want to achieve and one that you are getting
    • SOLVED Resizing problems, dragging when it is not allowed
      General and Desktop • resize qtwidgets dragging borderless wind • • Krakenus00  

      3
      0
      Votes
      3
      Posts
      144
      Views

      SetMinimumSize() does not work for me. I think it is because I change the window's position. However, the problem was in my form file. For an unknown reason, it changed the window's size to 802x600 when I was checking for 800x600. Maybe there was some another way out, but now all works just fine.
    • UNSOLVED Mac application built with 5.12.9 LTS hangs on launch under Big Sur
      General and Desktop • mac qtwidgets big sur • • calvinb  

      8
      0
      Votes
      8
      Posts
      1415
      Views

      @Nathan-Barel Yes it seems fixed in 5.12 and 5.15 https://bugreports.qt.io/browse/QTBUG-87014
    • UNSOLVED How to deploy Qt C++ Application on Windows when i used Visual Studio to create my application
      General and Desktop • c++ visual studio qt 5.4 qtwidgets • • learnist  

      6
      0
      Votes
      6
      Posts
      861
      Views

      To solve the VCINSTALLDIR problem, start the command prompt from your start menu -> Visual Studio 2017 -> x64 Native Tools Command Prompt (be sure not the ones with x86) Then call : set PATH=C:\Qt\5.14.1\msvc2017_64\bin;%PATH% to make both vc and qt dirs in your PATH. To force deploying the release binaries, add --release after windeployqt.
    • UNSOLVED Custom QCheckbox in QT widgets
      General and Desktop • stylesheet qtablewidget qtwidgets qcheckbox • • EagleSparrow  

      3
      0
      Votes
      3
      Posts
      282
      Views

      Here is the code. QList<SomeClass> ModeTableEntries ; for (int row = 0; row < ModeTableEntries .length(); row++) { ui->EntriesTableWidget->insertRow(row); ui->EntriesTableWidget->setRowHeight(row, 45); ModeValues value = ModeTableEntries [row]; QTableWidgetItem* currentItem = new QTableWidgetItem(value .ModeText); if(TestModeEnabled == true) currentItem->setCheckState(Qt::Checked); else currentItem->setCheckState(Qt::Unchecked); ui->EntriesTableWidget->setItem( row, 0, currentItem); currentItem->setFlags(currentItem->flags()^(Qt::ItemIsEditable )); } The problem is that I cannot style the default implementation of the QTableWidgetItem(QCheckbox) that is part of the QTableWidgetItem.
    • UNSOLVED How to Add multiple Qtoolbar in QtabWidget
      General and Desktop • qt5 qtabwidget qtwidgets qtoolbar tabs • • vicky_mac  

      4
      0
      Votes
      4
      Posts
      936
      Views

      @vicky_mac A QStackedWidget works like a book. You have pages with your content. You can flip these pages to change your widget inplace (without opening another window or something else). So one possibility is to put one of each QTabWidget (each with a different tabBar position) on a page of a QStackedWidget. You could flip the pages by clicking a dummy tab on each tabBar or you use a button to go to the next page. I know, this is not exactly what the widget in your image looks like :) @vicky_mac said in How to Add multiple Qtoolbar in QtabWidget: Haven't used QT much If you want a widget, that looks exactly like the one shown above, you could still try to subclass and create your own, custom TabWidget, but I fear, that it might be a little too challenging. Here's all you need to know about QStackedWidget (https://doc.qt.io/qt-5/qstackedwidget.html#details)
    • UNSOLVED Blurred background for Main window
      General and Desktop • qmainwindow qapplication qtwidgets qtgui • • shanmugaraja  

      3
      0
      Votes
      3
      Posts
      572
      Views

      Hi As far as I know, there is nothing like that in Qt. It can blur widgets but not the actual desktop.
    • UNSOLVED Align QPainterPath
      General and Desktop • qtwidgets qt 5.9.0 qlabe • • goldstar2154  

      2
      0
      Votes
      2
      Posts
      703
      Views

      UPD: I write this method for drawing, looks good { QLabel::paintEvent(event); QPainter painter (this); painter.setPen(Qt::green); painter.setBrush(palette().windowText()); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); painter.setFont(font()); QRect font_rect = painter.fontMetrics().boundingRect(text()); QRect label_rect = contentsRect(); label_rect.adjust(margin(), margin(), -margin(), -margin()); int dx = label_rect.width() - font_rect.width(); int dy = label_rect.height() - font_rect.height(); int x = 0; int y = 0; if (alignment() & Qt::AlignLeft) x = label_rect.left(); else if (alignment() & Qt::AlignHCenter) x = label_rect.left() + dx / 2; else if (alignment() & Qt::AlignRight) x = label_rect.right() - font_rect.width(); if (alignment() & Qt::AlignTop) y = label_rect.top() + font_rect.height(); else if (alignment() & Qt::AlignVCenter) y = label_rect.top() + dy / 2; else if (alignment() & Qt::AlignBottom) y = label_rect.bottom(); QPainterPath path; path.addText(x, y, font(), text()); painter.fillPath(path, palette().windowText()); painter.strokePath(path, QPen(QColor(255, 0, 0, 50), 2)); } But i still dont understand the difference btw native paint event and my own
    • UNSOLVED Seeking inspiration for direction orientation.
      General and Desktop • qtwidgets orientation • • Faruq  

      3
      0
      Votes
      3
      Posts
      402
      Views

      @Faruq QML (using Canvas element) and QtQWidgets (using QPainter in combination with QPainterPath) is capable of drawing such things. In either way it's all about the math and doing the calculations of each shape (arcs, lines, texts, ...) The bottom image is rather easy. Yyou just need to calculate the translation along the x-axis based on your input values which make up the direction.
    • SOLVED How we can read particular string/data from any device to print on particular LCD in qt?
      Mobile and Embedded • qtcreator qt5.5 qt4 qtwidgets read serial • • Mohit Tripathi  

      25
      0
      Votes
      25
      Posts
      6091
      Views

      Don't @ the moderators unless you have an issue requiring moderation. Depending on the content of your line edit, you can use toLatin1() or toUtf8() rather than making these two conversions.
    • SOLVED When i click a button i need the control to go back to main.cpp. In main.cpp it can be to any functions.
      Mobile and Embedded • c++ qt qtwidgets qt5.9 • • vyshak  

      6
      0
      Votes
      6
      Posts
      2209
      Views

      Thank you all, the issue is solved.
    • SOLVED Qt Widgets global stylesheet
      General and Desktop • stylesheet qtwidgets • • Tikani  

      8
      0
      Votes
      8
      Posts
      8020
      Views

      If you want stylesheet ready for the use of qss in your application use this site: https://qss-stock.devsecstudio.com
    • SOLVED Get margins of QPushButton
      General and Desktop • qtwidgets qss • • goldstar2154  

      13
      1
      Votes
      13
      Posts
      8401
      Views

      @goldstar2154 Totally agree with you - there is a obvious bug. But thanks to @raven-worx 's code we've got a way to get a result at least. And "solved" will help in web search:) Thank you very much for this question:)
    • UNSOLVED Completely custom menu in QtWidgets
      General and Desktop • qmenu qtwidgets material design context menu • • IMAN4K  

      10
      0
      Votes
      10
      Posts
      5009
      Views

      @IMAN4K Hi Im not sure what "material ripple animation" really is so its hard to say which design i would prefer. Copying Paint of QMenu would be last choice as there might be bugs and its involving to keep in sync. If the items can do all the drawing them self i would go for that. (2 i think :)
    • SOLVED Virtual keyboard does not show up in QWidgets app on RPi 2
      Mobile and Embedded • qt 5.7 qtwidgets virtualkeyboard cross-compile eglfs rpi2 • • mr_max  

      9
      1
      Votes
      9
      Posts
      6374
      Views

      @mr_max I also have the same issue..Is it working now?
    • UNSOLVED Undefined referance to class::function
      General and Desktop • qtdesigner qtwidgets class undefined refer • • fortyff  

      10
      0
      Votes
      10
      Posts
      4031
      Views

      @fortyff said in Undefined referance to class::function: There are the same errors occured in the "esimplelabel.cpp" file, but I didn't write down here, since it'll consume too much place. Make sure you have all virtual functions that are declared defined. While a declaration of a regular function without a definition is perfectly valid (until it's called), that's not true for virtual methods.
    • UNSOLVED How to style QTreeView items by role with CSS ?
      General and Desktop • qtreeview model-view css qtwidgets styles • • Zylann  

      9
      0
      Votes
      9
      Posts
      7865
      Views

      I finally managed to get custom colors. I gave my QTreeView an object name to be able to write this in CSS: m_treeView->setObjectName("MyTreeView"); m_treeView->setStyleSheet("QTreeView#MyTreeView::item {color: none;}"); basically now my model controls text color through Qt::ForegroundRole regardless of the application's CSS. I feel like it's the wrong place to put theming, but it works for me at the moment. Well... until we decide to have different themes :-°
    • UNSOLVED Using a Qt 5 Widget within a QML application?
      General and Desktop • qt5.5 qtwidgets • • A Former User  

      5
      0
      Votes
      5
      Posts
      6568
      Views

      Here is a method of capturing mouse events and wheel events based on the previous answer. Unfortunately, this method requires us to access protected members of the QWidget. I don't know how legal it is, but it works: Constructor: QmlPlainTextEdit::QmlPlainTextEdit(QQuickItem *parent) : QQuickPaintedItem(parent) { // Set item flags setFlag(ItemHasContents, true); setFlag(ItemAcceptsInputMethod, true); setFlag(ItemIsFocusScope, true); setAcceptedMouseButtons(Qt::AllButtons); // Initialize the text edit widget m_textEdit = new QPlainTextEdit(); m_textEdit->installEventFilter(this); m_textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); // Set the QML item's implicit size auto hint = m_textEdit->sizeHint(); setImplicitSize(hint.width(), hint.height()); // Resize QPlainTextEdit to fit QML item connect(this, &QQuickPaintedItem::widthChanged, this, &QmlPlainTextEdit::updateWidgetSize); connect(this, &QQuickPaintedItem::heightChanged, this, &QmlPlainTextEdit::updateWidgetSize); } Events: bool QmlPlainTextEdit::event(QEvent *event) { switch (event->type()) { case QEvent::FocusIn: forceActiveFocus(); return QQuickPaintedItem::event(event); break; case QEvent::Wheel: processWheelEvents(static_cast<QWheelEvent*>(event)); return true; break; case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: case QEvent::MouseMove: processMouseEvents(static_cast<QMouseEvent*>(event)); return true; break; default: break; } return QApplication::sendEvent(m_textEdit, event); } Event filter: bool QmlPlainTextEdit::eventFilter(QObject *watched, QEvent *event) { Q_ASSERT(m_textEdit); if (watched == m_textEdit) { switch (event->type()) { case QEvent::Paint: case QEvent::UpdateRequest: update(); break; default: break; } } return QQuickPaintedItem::eventFilter(watched, event); } Paint function: void QmlPlainTextEdit::paint(QPainter *painter) { if (m_textEdit && painter) m_textEdit->render(painter); } Process mouse/wheel events: Doing some tests, I found out that QPlainTextEdit::event() returned false for mouse and wheel events. The quick and dirty solution was to call the appropriate event handlers directly. However, these functions are protected, so we need to do some unorthodox things in order to call these functions: void QmlPlainTextEdit::processMouseEvents(QMouseEvent* event) { class Hack : public QPlainTextEdit{ public: using QPlainTextEdit::mousePressEvent; using QPlainTextEdit::mouseMoveEvent; using QPlainTextEdit::mouseReleaseEvent; using QPlainTextEdit::mouseDoubleClickEvent; }; auto hack = static_cast<Hack*>(m_textEdit); switch(event->type()) { case QEvent::MouseButtonPress: hack->mousePressEvent(event); break; case QEvent::MouseMove: hack->mouseMoveEvent(event); break; case QEvent::MouseButtonRelease: hack->mouseReleaseEvent(event); break; case QEvent::MouseButtonDblClick: hack->mouseDoubleClickEvent(event); break; default: break; } } void QmlPlainTextEdit::processWheelEvents(QWheelEvent* event) { class Hack : public QPlainTextEdit{ public: using QPlainTextEdit::wheelEvent; }; static_cast<Hack*>(m_textEdit)->wheelEvent(event); } Resize widget to fit QML item: void QmlPlainTextEdit::updateWidgetSize() { m_textEdit->setGeometry(0, 0, static_cast<int>(width()), static_cast<int>(height())); update(); } To use this class in QML, add in main.cpp: qmlRegisterType<QmlPlainTextEdit>("QtWidgets", 1, 0, "QmlPlainTextEdit"); And finally, the QML item would be used like: QmlPlainTextEdit { id: textEdit focus: true Layout.fillWidth: true Layout.fillHeight: true onFocusChanged: { textEdit.forceActiveFocus() } } If anybody has a better way to process mouse/wheel events for this scenario, please post it here. I was stuck with this issue for three days and this is the only solution that I found.
    • SOLVED Add QWidget containing other QWidgets onto QMainWindow
      General and Desktop • widgets mainwindow qtwidgets • • ChajusSaib  

      4
      0
      Votes
      4
      Posts
      5295
      Views

      You'r welcome ! Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)
    • How to Cross Compile Qt with Gstreamer1.0 support
      QtonPi • raspberry pi qtmultimedia qtwidgets xcb • • Haresh  

      1
      1
      Votes
      1
      Posts
      752
      Views

      No one has replied

    • Subwindows on MainWindow
      General and Desktop • qtwidgets • • Lays147  

      5
      0
      Votes
      5
      Posts
      3531
      Views

      Hi Lays, when you already have a layout set, you don't need to create a new one. Just access your existing Layout with the layout() function. In general every QWidget has its own layout (there are different kinds of layouts) and you can add widgets to them. So if you want to add a widget to your QMainWindows layout you can call inside your main windows code something like this: this->layout()->addWidget(new Widget); For further information please read http://doc.qt.io/qt-4.8/layout.html. Greetings AlexRoot
    • Your software deserves a great interface!
      Jobs • qml qtwidgets design • • Martin Zajac  

      4
      0
      Votes
      4
      Posts
      2108
      Views

      Nice! Thanks for sharing :)
    • In-App Console
      General and Desktop • qml qtwidgets console • • Maxim DC  

      4
      0
      Votes
      4
      Posts
      1396
      Views

      Oh, then it has nothing to do with a console or a console. qDebug is a text stream. To redirect output of qDebug use qInstallMessageHandler.
    • JavaScript with Qt Widget application
      QML and Qt Quick • qml javascript qtwidgets • • MTCA  

      10
      0
      Votes
      10
      Posts
      4558
      Views

      Ohh. Sounds great!! Thank you for adding some new things in my knowledge base. :)
    • QtWidgets: Is it possible to apply flat main window style (Visual Studio-like) via QSS?
      General and Desktop • css qtwidgets qss • • Violet Giraffe  

      15
      0
      Votes
      15
      Posts
      8199
      Views

      @Chris-Kawa I just have to say this is hilarious and spot on. I did this same thing in wxWidgets a couple years ago and this was my experience verbatim. In the end I went on to use the same basic technique that is described here: https://github.com/deimos1877/BorderlessWindow. Thanks for making me feel less stupid.
    • [SOLVED] How to move QGroupBox tittle to bottom side?
      General and Desktop • qtwidgets qstyle qgroupbox • • Vitek  

      3
      0
      Votes
      3
      Posts
      1438
      Views

      Hi, and thank you. For improve appearance might to add it "QGroupBox {margin-bottom: 3px;}" "QGroupBox::title { subcontrol-position: bottom; " " top: 3px; }"
    • QWebEngineView inside of QWidget
      QtWebEngine • qtwebengine qtwidgets • • Delta  

      2
      0
      Votes
      2
      Posts
      2424
      Views

      Well, it was caused by a QGraphicsEffect on the QWidget. After removing it, the QWebEngineView worked without any flaws. weird.
    • [SOLVED]Qt Creator default project not building
      General and Desktop • qtcreator build qtwidgets exe • • pigman980  

      10
      0
      Votes
      10
      Posts
      10812
      Views

      HI, I suggest to open a new post because you marked this as SOLVED. BTW if you moved to windows and want to see the debug output you should add CONFIG += console to your .pro file